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
https://forums.phpfreaks.com/topic/152245-error-wont-go-away/
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
https://forums.phpfreaks.com/topic/152245-error-wont-go-away/#findComment-803345
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
https://forums.phpfreaks.com/topic/152245-error-wont-go-away/#findComment-803347
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.