PHP Query Database error

Source: Internet
Author: User
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
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.