Home > php教程 > php手册 > php与mysql建立连接并执行SQL语句的代码_php入门_脚本之家

php与mysql建立连接并执行SQL语句的代码_php入门_脚本之家

WBOY
Release: 2016-06-06 20:38:03
Original
886 people have browsed it

进入2011年的暑假,已经要大三了,也该点更深刻的东西了。综合各方面的因素,决定还是先学习学习php,等有所掌获之后在去了解其他方面的东西。

今天写了一个小程序,很小很小,只不过是能够建立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";
?>
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template