bbram Posted February 21, 2011 Share Posted February 21, 2011 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, Quote Link to comment https://forums.phpfreaks.com/topic/228333-sql-syntax-error-to-check-manual/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 21, 2011 Share Posted February 21, 2011 You have an extra comma right before the FROM or you intended on selecting another column name but forgot to list it. Quote Link to comment https://forums.phpfreaks.com/topic/228333-sql-syntax-error-to-check-manual/#findComment-1177393 Share on other sites More sharing options...
bbram Posted February 21, 2011 Author Share Posted February 21, 2011 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']; Quote Link to comment https://forums.phpfreaks.com/topic/228333-sql-syntax-error-to-check-manual/#findComment-1177398 Share on other sites More sharing options...
sasa Posted February 21, 2011 Share Posted February 21, 2011 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] Quote Link to comment https://forums.phpfreaks.com/topic/228333-sql-syntax-error-to-check-manual/#findComment-1177490 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.