<?php require_once('Connections/conn.php');
$conn=mysql_connect("localhost","root","root")or die("不能连接到数据库");
mysql_select_db("user",$conn)or die("can't connect to the servers");
$reback=0;
$sql="select * from user where name="'.$_GET['user'].'"";
$rst=$conn->Execute($sql)or die('execute error');
if($ret->RecordCount()==1)
{
$reback='2';
} else
{
$reback='1';
} echo $reback;
?>提示$rst=$conn->Execute($sql)or die('execute error'); 这行有问题
Call to a member function Execute() on a non-object
$conn=mysql_connect("localhost","root","root")or die("不能连接到数据库");
mysql_select_db("user",$conn)or die("can't connect to the servers");
$reback=0;
$sql="select * from user where name="'.$_GET['user'].'"";
$rst=$conn->Execute($sql)or die('execute error');
if($ret->RecordCount()==1)
{
$reback='2';
} else
{
$reback='1';
} echo $reback;
?>提示$rst=$conn->Execute($sql)or die('execute error'); 这行有问题
Call to a member function Execute() on a non-object
$conn=mysql_connect("localhost","root","root")or die("不能连接到数据库");
mysql_select_db("user",$conn)or die("can't connect to the servers");
$reback=0;
$sql="select * from user where name='".$_GET['user']."'";
$rst=mysql_query($sql)or die('execute error'); //用mysql_query
if($ret->RecordCount()==1)
{
$reback='2';
}else
{
$reback='1';
}echo $reback;?>
这行又出问题了- -·
$conn=mysql_connect("localhost","root","root")or die("不能连接到数据库");
mysql_select_db("user",$conn)or die("can't connect to the servers");
$reback=0;
$sql="select * from user where name='".$_GET['user']."'";
$rst=mysql_query($sql)or die('execute error'); //用mysql_query
if(while ($row = mysql_fetch_assoc($rst)){
$reback='2';
}else{
$reback='1';
}echo $reback;?>
你要去看PHP手册上的例子
<?phprequire_once('Connections/conn.php');
$conn=mysql_connect("localhost","root","root")or die("不能连接到数据库");
mysql_select_db("user",$conn)or die("can't connect to the servers");
$reback=0;
$sql="select * from user where name='".$_GET['user']."'";
$rst=mysql_query($sql)or die('execute error'); //用mysql_query
while ($row = mysql_fetch_assoc($rst)){
print_r($rst);
}echo $reback;?>
把这句改成:
$sql="select * from user where name='".$_GET['user']."'";
注意单引号和双引号的位置。
或者干脆这样:
$sql="select * from user where name='{$_GET['user']}'";
单引号还能放单引号啊...