MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old January 15th, 2004, 08:25 PM
mjfmn mjfmn is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 1 mjfmn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Stuck on a "not a valid MySQL result resource " error

I'm trying to port over to a new website and get our php scripts to work and most work fine, but one that I have that sorts email addresses and puts them all in the "to" field is frustrating me! I did not write the original code, and I'm learning about PHP & MYSQL as I go.

I'll include all the code here. I've added the "or die .." code, but I keep getting the following error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/stpaulair/www/pars/spa-admin/test.php on line 19

Any help is appreciated - thanks!

Mike

===================
<html>
<head>
</head>
<body bgcolor="white">
<?
$dbuser = 'web';
$dbhost = 'localhost';
$dbpass = 'passwd';
$dbname = 'mpd';
$dbtable = 'mpr';
$flag=0;
//------ DATABASE CONNECTION --------//
mysql_connect($dbhost,$dbuser,$dbpass);
@mysql_select_db("mpd");

$sql2 = "SELECT * FROM $dbtable where 'staff'='1'";
$result2 = mysql_query($sql2) or die (mysql_error());
while($value = mysql_fetch_array($result2))

{
if ($flag!=0) {$recipients = $recipients . ", " . $value[7];}
if ($flag==0) {$recipients = $value[7]; $flag=1;}
}

$subject = stripcslashes($subject);
$message = stripcslashes($message);

mail("$recipients","$subject","$message","From: $email");

print("This email has been sent:<br>");

print("<br>To: $recipients<br><br>Subject: $subject<br><br>$message<br>");
?>
</body>
</html>

Reply With Quote
  #2  
Old February 27th, 2005, 05:50 PM
localworld localworld is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 1 localworld User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 31 sec
Reputation Power: 0
i too have run in to this problem a couple of times. i cannot seem to pinpoint the cause of this either. in my case the 'mysql_query($sql)' returns of type boolean rather than a mysql resource link

my mysql_connect is returning as a mysql resource just fine however.

i'll let ya know if i figure this out.. i've never had this problem until recently.

Reply With Quote
  #3  
Old February 28th, 2005, 08:04 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
This is often caused by a fault in your SQL statement.
I would recommend checking there first.

Try pasting it in the MySQL command line tool and see what gets returned

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > Stuck on a "not a valid MySQL result resource " error


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway