potter_gold Posted April 2, 2009 Share Posted April 2, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/152245-error-wont-go-away/ Share on other sites More sharing options...
fenway Posted April 2, 2009 Share Posted April 2, 2009 Post the query that's causing that error-- not the code. Quote Link to comment https://forums.phpfreaks.com/topic/152245-error-wont-go-away/#findComment-799644 Share on other sites More sharing options...
potter_gold Posted April 7, 2009 Author Share Posted April 7, 2009 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/152245-error-wont-go-away/#findComment-803345 Share on other sites More sharing options...
Yesideez Posted April 7, 2009 Share Posted April 7, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/152245-error-wont-go-away/#findComment-803347 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.