help needed

help needed

am 25.01.2008 15:59:08 von Peter D

Hi everyone!

I hope my request can be answered by someone. I'm new to PHP and whole
server issue!

I'm trying to test my PHP scripts locally on my PC. It seems
Apache/PHP/MySql and PhpMyAdmin are working correctly when I test simple php
files. Here's the problem :

I have two files:

"display_scores.php" and "db.php".

Here's the "display_scores.php"

----------------------------------------------------


include("db.php");

$table = 'high_score';

mysql_connect ($host, $user, $pass);

mysql_select_db ($database);

$result = mysql_query ( "SELECT * FROM 'high_score' ORDER BY score DESC
LIMIT 10");

$row = mysql_fetch_array($result);

extract($row);

echo "$player : $score ";

?>

----------------------------------------------------

and here's the "db.php" file:

------------------------------------------------------


$host = '127.0.0.1.:3306';

$user = 'root';

$pass = '1234';

$database = 'cartoon_smart_courses';

$table = 'high_score';

-----------------------------------------------------

When I test the "display_scores.php" on my browser, following messages show:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in
D:\SERVER\Cartoon_smart_series\flash_php_mysql_part1\display _scores.php on
line 12

Warning: extract() [function.extract]: First argument should be an array in
D:\SERVER\Cartoon_smart_series\flash_php_mysql_part1\display _scores.php on
line 13

---------------------------------

Where is the problem? Can someone help? Please?

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: help needed

am 25.01.2008 16:20:46 von Stut

Peter D wrote:
> $result = mysql_query ( "SELECT * FROM 'high_score' ORDER BY score DESC
> LIMIT 10");

Single quotes are invalid around entity names, you should be using
backticks to surround high_score.

You really should be checking the return value from mysql_query. It
tells you if an error occurred, and you can then use mysql_error to get
more details.

-Stut

--
http://stut.net/

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php