Jump to content

Warning: mysql_fetch_array()


potter_gold

Recommended Posts

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

Link to comment
Share on other sites

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);

?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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.