php连接MySQL
error_reporting(E_ALL & ~E_DEPRECATED); header('Content-type:text/html;charset=utf8'); $conn = mysql_connect('localhost','root','root') or die("<script>alert('连接MySQL失败,请重试!');</script>"); mysql_set_charset('utf8');//5.5以下适用php连接数据库
$select = mysql_select_db('student') or die("<script>alert('连接数据库失败,请重试!');</script>");增删改查
$sql = "select * from student"; $insert_sql = "insert into student values ('default','张三','23')"; $update_sql = "update student set name = '李四' where id = 7"; $delete_sql = "delete from student where id = 7"; $query = mysql_query($insert_sql)//此时$query是一个数组 or die("<script>alert('查询失败,请重试!');</script>");