PHP MYSQL error

I am getting following error in my php page.


$username="xxx";
$password="xxx";
$database="xxx";

mysql_connect('xxxxxxxxxx',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = mysql_query("SELECT * FROM rgames_flash WHERE GameAlive = '1' ORDER BY GameID DESC LIMIT 0, 25");

$result=mysql_query($query);
$num=mysql_numrows($result) or die (mysql_error());

mysql_close();

Please help me to solve this error.

the error in these 2 lines is obvious.

what were you trying to do there?

Yeah what he said ^^

$query = mysql_query("SELECT * FROM rgames_flash WHERE GameAlive = '1' ORDER BY GameID DESC LIMIT 0, 25");

$result=mysql_fetch_array($query);
print_r($result);

Whats the difference between that two?.. i want to know just for my knowledge. I did not see any diff, both will give the same results, right?

$num=mysql_numrows($result) or die (mysql_error());

Isn’t it be:

$num=mysql_num_rows($result) or die (mysql_error());

As mysql_numrows is deprecated.

I am trying to get last 25 results in db.

If I use mysql_fetch_array($query) I get this output with error

Read This For More info

Got the solution.

Change this line
//$query = mysql_query(“SELECT GameId, GameName, GameDesc FROM rgames_flash WHERE GameAlive = ‘1’ ORDER BY GameID DESC LIMIT 0, 25”);

to
$query = “SELECT GameId, GameName, GameDesc FROM rgames_flash WHERE GameAlive = ‘1’ ORDER BY GameID DESC LIMIT 0, 25”;
$result=mysql_query($query);

well done - glad you sorted it out in the end :slight_smile:

The way the code was originally…

$query was running the mysql_query, then $result was trying to run the mysql_query of a mysql_query… which of course will just confuse poor MySQL.

And yes, mysql_numrows has been depreciated for some time.

@LSC-Rob,
Thanks for the info, but i know all that as i am following the thread.
I was referring to the OP this line:


//$query = mysql_query("SELECT GameId, GameName, GameDesc FROM rgames_flash WHERE GameAlive = '1' ORDER BY GameID DESC LIMIT 0, 25");

to this

$query = "SELECT GameId, GameName, GameDesc FROM rgames_flash WHERE GameAlive = '1' ORDER BY GameID DESC LIMIT 0, 25";
$result=mysql_query($query);

As if the OP run the 1st query without $result with mysql_query, it will be the same as $result taking out mysql_query from $query.
I was just curious about that, because both are the same:


$query = mysql_query("SELECT GameId, GameName, GameDesc FROM rgames_flash WHERE GameAlive = '1' ORDER BY GameID DESC LIMIT 0, 25");

No $result above.
same as:

$query = "SELECT GameId, GameName, GameDesc FROM rgames_flash WHERE GameAlive = '1' ORDER BY GameID DESC LIMIT 0, 25";
$result=mysql_query($query);

Hope its clear as i was trying to focus on that point. :slight_smile:

Now I get ya… Sorry, it’s been a long day!

In that case, yes, AFAIK, the end result should be the same with either method… A bit of extra code with one, but a bit less readable with the other.