php establishes a connection with mysql and executes the code for the SQL statement

  • 2020-05-09 18:17:55
  • OfStack

Today, I wrote a small program, very small, but can establish php and mysql link, and implement simple SQL statement.

Novice first try, also ask each master to guide more.

Program source code is as follows:
 
<?php 
$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"; 
?> 

Related articles: