Re: syntax error help
| From: | Bigmark | Date: | Sun, 20 Aug 2006 11:17:18 +0000 |
| Subject: | Re: syntax error help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-240919@lists.php.net to get a copy of this message | ||
It works now: I replaced the last part of the sql with a variable
<?php
$sql = "SELECT COUNT(*) FROM leaderboard WHERE points >= $my_points ";
$result = mysql_query( $sql ) or die ( mysql_error() );
$rank = mysql_result( $result, 0 );
echo $rank;
?>
""Bigmark"" <neretlis@westnet.com.au> wrote in message
news:F7.A0.03273.10738E44@pb1.pair.com...
> Can anyone tell me why this works on my localhost but gets an error on my
> server:
>
> <?php
> $sql = "SELECT COUNT(*) FROM leaderboard WHERE points >=( SELECT points
> FROM
> leaderboard WHERE username= '$username' )";
> $result = mysql_query( $sql ) or die ( mysql_error() );
> $rank = mysql_result( $result, 0 );
> echo $rank;
> ?>
>
>
> this is the error message but i cant figure it out:
>
> Your Position You have an error in your SQL syntax. Check the manual that
> corresponds to your MySQL server version for the right syntax to use near
> 'SELECT points FROM leaderboard WHERE username= 'ainslie' )' at