PHP连接MYSQL操作数据库
PHP连接MYSQL操作数据库
<?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } if (mysql_query("CREATE DATABASE MYDB1",$con)) { echo "Database created"; } else { echo "Error creating database: " . mysql_error(); } mysql_selectdb("MYDB1",$con); $sql=' CREATE TABLE Persons ( FirstName varchar(15), LastName varchar(15), age int ) '; if(mysql_query($sql,$con)) { echo 'Table Created'; } else { echo mysql_error(); } mysql_close($con); ?>
转载请注明文章来自:程序猴(http://www.chengxuhou.com/)
posted on 2014-01-08 14:03 程序猴chengxuhou.com 阅读(351) 评论(0) 编辑 收藏 举报