Home  >  Article  >  Backend Development  >  php与mysql建立连接并执行SQL语句的代码_PHP

php与mysql建立连接并执行SQL语句的代码_PHP

WBOY
WBOYOriginal
2016-06-01 12:16:29868browse

今天写了一个小程序,很小很小,只不过是能够建立php与mysql的链接,并且实现简单的SQL语句。

新手初试,还请各路高手多多指导。

程序源代码如下:
复制代码 代码如下:
$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";
?>

Statement:
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