Jump to content

SQL syntax error to check manual


bbram

Recommended Posts

Hello I have the following error:

 

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 'FROM players WHERE ((NOT inactive_player) AND ((players.Player_Last_Name = 'p' at line 3

 

I think my error is in the statement below...

 

 

echo "1";
$getNewPlayers = 
"SELECT players.Player_number, 
	players.Player_name, 
FROM players
WHERE ((NOT inactive_player)
AND ((players.Player_Last_Name = 'player_find%')))
ORDER BY player_name";
$rsNewPlayers = mysql_query($getNewPlayers, $link) or die (mysql_error());
$varNewCount = mysql_num_rows($rsNewPlayers);
echo $varNewCount['Player_name'];

 

Can you tell me where the error is and how I might go about to fix it?

 

Thanks,

 

Link to comment
https://forums.phpfreaks.com/topic/228333-sql-syntax-error-to-check-manual/
Share on other sites

Okay I got it fixed thanks for your help...

 

Now my query is not displaying any information...

 

$countPlayers=mysql_query("SELECT players.Player_number, 
	players.Player_name 
FROM players
WHERE ((NOT Inactive_player)
AND ((players.Player_Last_Name = '$player_find%')))
ORDER BY Player_name");

$row = mysql_fetch_assoc($countPlayers) or die("No rows returned by query"); 
echo $row['Player_number'];

if you want to mach just start of last name try

$countPlayers=mysql_query("SELECT players.Player_number, 
	players.Player_name 
FROM players
WHERE ((NOT Inactive_player)
AND (players.Player_Last_Name LIKE '$player_find%'))
ORDER BY Player_name");

or if you want to mach hole last name

$countPlayers=mysql_query("SELECT players.Player_number, 
	players.Player_name 
FROM players
WHERE ((NOT Inactive_player)
AND ((players.Player_Last_Name = '$player_find')))
ORDER BY Player_name");

$row = mysql_fetch_assoc($countPlayers) or die("No rows returned by query"); 
echo $row['Player_number'];

 

$row = mysql_fetch_assoc($countPlayers) or die("No rows returned by query");

echo $row['Player_number'];[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.