potter_gold Posted August 7, 2010 Share Posted August 7, 2010 Hi All, I am sorry to bother you but wondered if you might be able to spot my mistake... When I click on this page http://www.freepspwallpaper.co.uk/free-psp-wallpapers/free-babes-psp-wallpapers/ if returns an error as below (look carefully its hidden behind the header color). Im a bit of a newbie and cannot seem to remove it. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/freepspw/public_html/dbconnect.php on line 22 Can anyone help? Peter Quote Link to comment https://forums.phpfreaks.com/topic/210086-warning-mysql_fetch_array/ Share on other sites More sharing options...
RussellReal Posted August 7, 2010 Share Posted August 7, 2010 show some code man - Russell Quote Link to comment https://forums.phpfreaks.com/topic/210086-warning-mysql_fetch_array/#findComment-1096422 Share on other sites More sharing options...
potter_gold Posted August 7, 2010 Author Share Posted August 7, 2010 Sorry russ, im very new. This is the file which it states a problem with line 22 is this line 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/>'; <?php // Declare the config as globals. define('DB_USERNAME','freepspw'); define('DB_PASS','ungoah615233'); define('DB_HOST','localhost'); define('DB_NAME','freepspw_freepsp'); // 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/210086-warning-mysql_fetch_array/#findComment-1096424 Share on other sites More sharing options...
potter_gold Posted August 7, 2010 Author Share Posted August 7, 2010 Does that make sense Russell? Quote Link to comment https://forums.phpfreaks.com/topic/210086-warning-mysql_fetch_array/#findComment-1096430 Share on other sites More sharing options...
RussellReal Posted August 7, 2010 Share Posted August 7, 2010 after this line $query = mysql_query($sql); add this line: echo mysql_error(); I suspect that the error is telling you that the table you're trying to access doesn't exist SIDE NOTE (edit): You will probably want to change your mysql credentials when your site goes live, as it is now public information and if you're going to be dealing with money you're gonna want to have your mysql info not as public aswell as your table name, because that is the big "?" when sql injecting Quote Link to comment https://forums.phpfreaks.com/topic/210086-warning-mysql_fetch_array/#findComment-1096459 Share on other sites More sharing options...
potter_gold Posted August 8, 2010 Author Share Posted August 8, 2010 Russell, That is amazing cheers. I inserted the code you suggested and it popped up to tell me that it could not find categories. This was because there was no such table in my php admin. I have changed to the required database. Many thanks. I will also change passwords as suggested - Good call. Peter Quote Link to comment https://forums.phpfreaks.com/topic/210086-warning-mysql_fetch_array/#findComment-1096751 Share on other sites More sharing options...
RussellReal Posted August 8, 2010 Share Posted August 8, 2010 anytime man you got my username, if there is ever a question that takes too long to get answered just send me over a PM I've got a bit of freetime every now and then (the life of a developer) Quote Link to comment https://forums.phpfreaks.com/topic/210086-warning-mysql_fetch_array/#findComment-1096759 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.