toolman Posted February 15, 2010 Share Posted February 15, 2010 I am getting an error message with this code: require_once 'tabconf.php'; $query = "SELECT ad_number_display FROM tabAdministration"; $result = mysql_query($query); $row = mysql_fetch_array($result); $numads = $row['ad_number_display']; $query = "SELECT ad_title, ad_text, ad_url FROM tabAdBids WHERE paypal_status = 'Completed' ORDER BY date_paid DESC LIMIT ".$numads; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { $ads[] = array('title' => $row['ad_title'], 'text' => $row['ad_text'], 'url' => $row['ad_url']); } [/ph] Can anyone see whats wrong? This is the error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource on line 9. Line 9 is: [code=php:0] while($row = mysql_fetch_array($result)) { Thanks Link to comment https://forums.phpfreaks.com/topic/192174-error-with-this-code/ Share on other sites More sharing options...
garethhall Posted February 15, 2010 Share Posted February 15, 2010 I am not completely sure but are you sure this is correct? $query = "SELECT ad_title, ad_text, ad_url FROM tabAdBids WHERE paypal_status = 'Completed' ORDER BY date_paid DESC LIMIT ".$numads; May echo it out and run it in phpMyAdmin or database app and see you get the right result. Last thing I can say for not is maybe change the second set of variable to be different name and on the same (It's just good practice) Link to comment https://forums.phpfreaks.com/topic/192174-error-with-this-code/#findComment-1012791 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.