joshgarrod Posted June 15, 2009 Share Posted June 15, 2009 Hi, I am getting the warning quoted below. However, it only comes up since I have "included" another script, when I remove it, the warning doesn't appear. All the code seems to be working fine. The page the warning is referring to isn't even the file being "included"???: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Users\website\view_article.php on line 26 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/162219-solved-why-would-i-get-this-warning/ Share on other sites More sharing options...
GingerRobot Posted June 15, 2009 Share Posted June 15, 2009 We're probably going to need to see some code. It might a variable issue -- the included file might have some variables with the same names as those in the file doing the including and thus it's screwing things up. But without any code, i'm just stabbing in the dark really. Quote Link to comment https://forums.phpfreaks.com/topic/162219-solved-why-would-i-get-this-warning/#findComment-856100 Share on other sites More sharing options...
joshgarrod Posted June 15, 2009 Author Share Posted June 15, 2009 I think it probably is duplicate variable names, it doesn't really matter then I guess as it won't show when it's live. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/162219-solved-why-would-i-get-this-warning/#findComment-856101 Share on other sites More sharing options...
GingerRobot Posted June 15, 2009 Share Posted June 15, 2009 I think it probably is duplicate variable names, it doesn't really matter then I guess as it won't show when it's live. Thanks Why would it not 'show' when it's live? Quote Link to comment https://forums.phpfreaks.com/topic/162219-solved-why-would-i-get-this-warning/#findComment-856103 Share on other sites More sharing options...
joshgarrod Posted June 15, 2009 Author Share Posted June 15, 2009 because I will turn off error reporting Quote Link to comment https://forums.phpfreaks.com/topic/162219-solved-why-would-i-get-this-warning/#findComment-856109 Share on other sites More sharing options...
GingerRobot Posted June 15, 2009 Share Posted June 15, 2009 because I will turn off error reporting But that doesn't mean the error has just gone away. It just means you're leaving it un-addressed. That's really not a good idea. Quote Link to comment https://forums.phpfreaks.com/topic/162219-solved-why-would-i-get-this-warning/#findComment-856110 Share on other sites More sharing options...
MadTechie Posted June 15, 2009 Share Posted June 15, 2009 LOL, That's a good idea, from now on I am going change my documentation and call all the bugs features! Can you post lines, a few lines around line 26 of view_article.php code feel free to leave it in the system but its really not recommended Quote Link to comment https://forums.phpfreaks.com/topic/162219-solved-why-would-i-get-this-warning/#findComment-856115 Share on other sites More sharing options...
joshgarrod Posted June 15, 2009 Author Share Posted June 15, 2009 Here is my code: <?php if(mysql_num_rows($query)==0){ die("Sorry, but the page doesnt exist!"); }else{ while($info = mysql_fetch_array($query)){ $title = $info ['title']; $category = $info ['category']; $content = $info ['content']; $postby = $info ['postby']; $timedate = $info ['timedate']; $image = $info ['image']; function custom_title($info) //sets the function to create the custom title { $title = $info ['title']; return "$title - Blog - About Caravans"; } function custom_keywords($info) //sets the function to create the custom keywords for meta tags { $title = $info ['title']; $category = $info ['category']; return "$title, $category, caravan blog, motorhome blog"; } function custom_desc($info) //sets the function to create a custom meta description { $title = $info ['title']; return "$title blog entry. Find more at www.aboutcaravans.co.uk"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/162219-solved-why-would-i-get-this-warning/#findComment-856162 Share on other sites More sharing options...
MadTechie Posted June 15, 2009 Share Posted June 15, 2009 is that the full page of "view_article.php"? where is $query set ? Quote Link to comment https://forums.phpfreaks.com/topic/162219-solved-why-would-i-get-this-warning/#findComment-856172 Share on other sites More sharing options...
joshgarrod Posted June 15, 2009 Author Share Posted June 15, 2009 that is not the full code, just the code around line 26 Quote Link to comment https://forums.phpfreaks.com/topic/162219-solved-why-would-i-get-this-warning/#findComment-856186 Share on other sites More sharing options...
MadTechie Posted June 15, 2009 Share Posted June 15, 2009 where is $query set ? Quote Link to comment https://forums.phpfreaks.com/topic/162219-solved-why-would-i-get-this-warning/#findComment-856192 Share on other sites More sharing options...
joshgarrod Posted June 15, 2009 Author Share Posted June 15, 2009 This is the complete section of code: <?php //error_reporting(E_ALL); $con = mysql_connect("host","user","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("quest", $con); $page = $_GET['ref']; // This will be the ID of the page $page = mysql_real_escape_string(strip_tags($page)); $query = mysql_query("SELECT * FROM articles WHERE `ref` = '$page'"); if(mysql_num_rows($query)==0){ die("Sorry, but the page doesnt exist!"); }else{ while($info = mysql_fetch_array($query)){ $title = $info ['title']; $category = $info ['category']; $content = $info ['content']; $postby = $info ['postby']; $timedate = $info ['timedate']; $image = $info ['image']; function custom_title($info) //sets the function to create the custom title { $title = $info ['title']; return "$title - Blog - About Caravans"; } function custom_keywords($info) //sets the function to create the custom keywords for meta tags { $title = $info ['title']; $category = $info ['category']; return "$title, $category, caravan blog, motorhome blog"; } function custom_desc($info) //sets the function to create a custom meta description { $title = $info ['title']; return "$title blog entry. Find more at www.aboutcaravans.co.uk"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/162219-solved-why-would-i-get-this-warning/#findComment-856196 Share on other sites More sharing options...
PFMaBiSmAd Posted June 15, 2009 Share Posted June 15, 2009 It's likely that something in the remainder of the actual code in your while() loop is reusing $query. You are also defining functions inside of the loop. As soon as you fix the current error and the loop executes more than once, your code will experience a fatal runtime error and abort at the first function definition that is inside of that loop. Quote Link to comment https://forums.phpfreaks.com/topic/162219-solved-why-would-i-get-this-warning/#findComment-856207 Share on other sites More sharing options...
joshgarrod Posted June 15, 2009 Author Share Posted June 15, 2009 Thanks, for your input everyone. It was the looping and recalling the variables from $query Quote Link to comment https://forums.phpfreaks.com/topic/162219-solved-why-would-i-get-this-warning/#findComment-856257 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.