PHP Query Database error,
PHP Code
Define ("Mysql_server_name", "localhost");d efine ("Mysql_username", "root");d efine ("Mysql_password", "");d Efine (" Mysql_database "," Test ");d efine (" table_name "," Voicemail "); Connect the database SERVER address, user name, password $conn = mysql_connect (Mysql_server_name,mysql_username,mysql_password) or Die ("Sorry, Could not connect to MySQL server! "); Select Database mysql_select_db (mysql_database, $conn) or Die ("Select Database Fial!"); PHP should be aware of anti-injection //escaping in "single quote, double quote, backslash, NULL," add backslash $uniqueid = addslashes ($uniqueid); $sql = "Select * from". table_name. "Where UniqueID = ' $uniqueid '"; echo $sql; Fetch to result set $result = mysql_query ($sql) or Die ("SQL query fail"); Cursor while ($row = Mysql_fetch_row ($result)) { echo $row ["billsec"]; } Close connection mysql_close ();
How did he die when he was in query-----SQL query fail?
How do you know what's wrong?
I am a beginner. Thank you first.
------Solution--------------------
As I said PHP is the best language, the direct echo mysql_error (); is stronger than anything else.
Don't you think Java's exception capture is annoying?
------Solution--------------------
1, I want to use PHP as Java to choose a framework to be used.
2, there, php.net website php manual is every PHP programmer should always keep the page open, there is a problem on the search. For example, you want to find a preparestatment automatic anti-injection function, because this is MySQL-related, so search: MySQL, find useful information inside to get this page: http://cn2.php.net/manual/zh/ Mysqli.prepare.php, also known as Mysqli,i, is a reinforced version of MySQL.
3, whatever you, the framework with who is not used, will what with what, will not pick one of the simplest
4, there, directly within the class static $i = XXX;, access is also classname:: $i.
5, a request to run a script, run through the process are destroyed, do not worry.
6, no bottleneck.
7, programmer-related, language-independent