clodhoppers18 Posted July 2, 2007 Share Posted July 2, 2007 I have tried altering my code below, but I continuously get "Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\wamp\www\setlastpurchase.php on line 82" and I cannot figure out what the problem is. Here is the code below. I dont really care if you see my database connection info, cause it is on a network that is JUST an internal network, with no network access. If anyone can provide any help, I would greatfully appreciate that. Dustin ??? <?php $cfg['mysql_server'] = 'localhost'; $cfg['database'] = 'mailinglist'; $cfg['user'] = 'root'; $cfg['passwordbase'] = ''; $db = @mysql_connect($cfg['mysql_server'], $cfg['user'], $cfg['passwordbase']); //////////////includied to show where $calldate is from//////////////// while ($query = "SELECT * FROM `mailinglist`.`calls` WHERE `processed` = 0 LIMIT 0, 1") { $result = @mysql_query($query, $db); $row = mysql_fetch_assoc($result); $calldate = $row["Date"]; ///////////////////////////////////////////////////////////////////// $result8 = @mysql_query("SELECT * FROM `marketing` WHERE `Date` = '$calldate'", $db); //Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\wamp\www\setlastpurchase.php on line 82 (next line)// $row8 = mysql_fetch_assoc($result8); $oldsalesmarketing = $row8["Sales"]; $marketingdate = $row8["Date"]; if (!$marketingdate) {// Run query mysql_query("INSERT INTO `marketing`(`Date`, 'Month', 'Day', 'Year', 'Sales') VALUES('$calldate', '$callmonth', '$callday', '$callyear', '1')", $db); echo "<br>WAS Empty"; $newsalesmarketing = 1; } else { echo "<br>Not Empty"; $newsalesmarketing = $oldsalesmarketing + 5; $query6 = "UPDATE `mailinglist`.`marketing` SET `Sales` = '$newsalesmarketing' WHERE `marketing`.`Date` = '$calldate'"; $result6 = @mysql_query($query6, $db); } ?> Link to comment https://forums.phpfreaks.com/topic/58121-need-some-help-with-mysql_fetch_assoc/ Share on other sites More sharing options...
Wildbug Posted July 2, 2007 Share Posted July 2, 2007 You need to do some debugging. Check for errors after mysql_query() statements. It's likely one failed and you're trying to read an invalid resource handle. mysql_query($query); if (mysql_errno()) echo "$query<br>\n" and die (mysql_error()); Link to comment https://forums.phpfreaks.com/topic/58121-need-some-help-with-mysql_fetch_assoc/#findComment-288271 Share on other sites More sharing options...
skali Posted July 3, 2007 Share Posted July 3, 2007 remove @ from the front of queries, try running the query from mysql client to see if the query is running fine. Link to comment https://forums.phpfreaks.com/topic/58121-need-some-help-with-mysql_fetch_assoc/#findComment-288924 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.