Jump to content

Error wont go away?


potter_gold

Recommended Posts

 

Hi

 

My first post,  I have an error on a query and do not know how to fix it.  Can anyone help me?

 

Peter

 

It is as follows and appears on this page http://www.freepspwallpaper.co.uk/free-psp-wallpapers/free-babes-psp-wallpapers/

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/freepspw/public_html/dbconnect.php on line 22

 

Link to comment
Share on other sites

So sorry Fenway. 

 

This is the error

 

while ($row = mysql_fetch_array($query)) {
   $catlinks .= ' <img src="bullet.gif" width="7" height="7" border="0" align="center"><a href="viewcategory.php?cid='.$row['wallpaperid'].'">'.$row['categoryid'].'</A><br/>';
}

 

-----

 

This is the rest of the code within my dbconnect file - minus rows for usernames and passwords.

 

// Connect to the database.
$database_connection = mysql_connect(DB_HOST, DB_USERNAME, DB_PASS);
mysql_select_db(DB_NAME);

require('class.pagedresults.php');

// Create the navbar.

// Select what we want.
$sql = 'SELECT * FROM `categories`';

$query = mysql_query($sql);
$catlinks = ' <img src="bullet.gif" width="7" height="7" border="0" align="center"><a HREF="http://www.freepspwallpaper.co.uk">Home</A><br/>';

while ($row = mysql_fetch_array($query)) {
   $catlinks .= ' <img src="bullet.gif" width="7" height="7" border="0" align="center"><a href="viewcategory.php?cid='.$row['wallpaperid'].'">'.$row['categoryid'].'</A><br/>';
}
$template = file_get_contents('template.php');
$template = str_replace('{LINKS}',$catlinks,$template);
?>

Link to comment
Share on other sites

First - please surround any PHP with PHP tags like this:

echo '[code=php:0] to start and end with 

';[/code]

 

This makes reading source a lot easier.

 

Second, with PHP the error line returned is often not the line in question that has the error.

 

With that type of error message (invalid query) the error won't really be in the mysql_query() call but the line previously somewhere where the query itself is being defined, example:

$query="SELECT * FROM table WHERE field!=field";

 

That's got the error because MySQL uses <> for not equals to and not !=

 

Can you post the query please?

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.