Home > Backend Development > PHP Tutorial > sql if statement PHP establishes a connection with mysql and executes the code of the SQL statement

sql if statement PHP establishes a connection with mysql and executes the code of the SQL statement

WBOY
Release: 2016-07-29 08:46:04
Original
1111 people have browsed it

Today I wrote a small program, which is very small. It can only establish a link between php and mysql and implement simple SQL statements.
It’s the first time for a novice, please give guidance from experts.
The program source code is as follows:

Copy the code The code is 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 introduces the code for sql if statement, PHP to establish connection with mysql and execute SQL statement, including the content of sql if statement. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template