SQL if statement PHP establishes a connection to MySQL and executes the code of the SQL statement

Source: Internet
Author: User
Tags php and mysql
Today I wrote a small program, small and small, just to build a link between PHP and MySQL, and implement simple SQL statements.
Novice preliminary interview, but also please a lot of experts to guide the road.
The program source code is as follows:

Copy the Code code as follows:


$conn = mysql_connect ("localhost", "root", "") or Die ("wrong!");
$sel =mysql_select_db ("MyDB", $conn);
$sql = "INSERT into ' mydb '. ' Test ' (
' ID ',
' UID ',
' RegDate ',
' Remark '
)
VALUES (
', ' php200 ', now (), ' dddd '
) ";
$que =mysql_query ($sql, $conn);
if ($que)
echo "true";
Else
echo "wrong";
?>

The above describes the SQL if statement PHP and MySQL to establish a connection and execute the SQL statement code, including the contents of the SQL if statement, I hope to be interested in PHP tutorial friends helpful.

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