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.