我正在使用wamp。我试图插入数据但它未定义数据库连接的常量错误

时间:2017-03-30 23:34:21

标签: php mysql

<?php
$id=$_POST['id'];
$sname=$_POST['sname'];
$age=$_POST['age'];
$fname=$_POST['fname'];
$room=$_POST['room'];

$array_room=array();
$count=0;
for($x=0;$x<count($array_room);$x++){
    if($id==$array_room[$x]){
        $count++;
    }
}   
if($count==3){
echo "maxed out";
}
else{
    array_push($array_room,$id);
}   

/ *到此处工作正常

$db=mysql_connect("localhost","root","root");
if(!db)
exit("could not connect to mysql");

$er=mysql_select_db("test");
if(!er)
exit("couldnt select database");

$insert="INSERT INTO student_info VALUES ($id,$sname,$age,$fname,$room)";

$result=mysql_query($insert);
if(!result)
exit("query couldnot be executed");

print "record inserted";
?>

/ *错误 使用未定义的常量db - 假设'db' 使用未定义的常数 - 假设'呃' 使用未定义的常量结果 - 假设'结果' * /

0 个答案:

没有答案
相关问题