zhshero Posted April 11, 2012 Share Posted April 11, 2012 Unable to execute query (SELECT * FROM lb-players) in the database : 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 '-players' at line 1 I don't know why i am getting this error. All i can think of that is taking away lb from "lb-players" when you add a " - "? [m]<?php $conn = mysql_connect("23.23.23.23", "unknown", "itsAsecertxD");//ignore this xD if (!$conn) { echo "Unable to connect to the database : " . mysql_error(); exit; } if (!mysql_select_db("minecraft-rc")) { echo "Unable to select database mydbname : " . mysql_error(); exit; } $sql = 'SELECT * FROM lb-players'; $result = mysql_query($sql); if (!$result) { echo "Unable to execute query ($sql) in the database : " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to display."; exit; } while ($row = mysql_fetch_assoc($result)) { echo $row["playername"]; } mysql_free_result($result); ?>[/m] tell me if i posted this in the wrong place its been forever since i last been on this site :$ Link to comment https://forums.phpfreaks.com/topic/260721-unable-to-execute-query/ Share on other sites More sharing options...
Sajesh Mohan Posted April 11, 2012 Share Posted April 11, 2012 the code is correct and working me correctly. <?php $conn = mysql_connect("localhost", "root", "");//ignore this xD if (!$conn) { echo "Unable to connect to the database : " . mysql_error(); exit; } if (!mysql_select_db("salhia_arabic")) { echo "Unable to select database mydbname : " . mysql_error(); exit; } $sql = 'SELECT * FROM st_admin'; $result = mysql_query($sql); if (!$result) { echo "Unable to execute query ($sql) in the database : " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to display."; exit; } while ($row = mysql_fetch_assoc($result)) { echo $row["admin_username"]; } mysql_free_result($result); ?> Link to comment https://forums.phpfreaks.com/topic/260721-unable-to-execute-query/#findComment-1336279 Share on other sites More sharing options...
zhshero Posted April 11, 2012 Author Share Posted April 11, 2012 I figure it out and btw your only working b/c you have a _ in the table name i have the - in there but this world below for me $sql = 'SELECT * FROM `lb-players`'; Link to comment https://forums.phpfreaks.com/topic/260721-unable-to-execute-query/#findComment-1336283 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.