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

WBOY
Release: 2016-07-21 15:26:51
Original
919 people have browsed it

今天写了一个小程序,很小很小,只不过是能够建立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";
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/323864.htmlTechArticle今天写了一个小程序,很小很小,只不过是能够建立php与mysql的链接,并且实现简单的SQL语句。 新手初试,还请各路高手多多指导。 程序源...
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!