Jump to content

[SOLVED] Why would I get this warning?


joshgarrod

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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";
					}
					?>

Link to comment
Share on other sites

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";
					}
					?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.