我想通過檢查他的電子郵件是否已經存在於我的'賣家'表上來檢查用戶是否已經在那裏。如果存在,我想跳過插入新記錄,否則插入新的賣家。代碼如下:mysql_num_rows()期望參數1是資源,對象
$email = $_REQUEST['semail'];
$sql = 'SELECT Email FROM project2.sellers WHERE Email = :email';
$s = $pdo->prepare($sql);
$s->bindValue(':email', $email);
$s->execute();
if (!$s) {
}
if (mysql_num_rows($s)!=0) {
echo "exists";
}
else
{
$sql = 'INSERT INTO project2.sellers SET
Type = :stype;
Name = :sname;
Email = :semail;
Phone = :sphone;
Location = :location;
City = :city';
$s = $pdo->prepare($sql);
$s->bindValue(':stype', $_REQUEST['stype']);
$s->bindValue(':sname', $_REQUEST['sname']);
$s->bindValue(':semail', $_REQUEST['semail']);
$s->bindValue(':sphone', $_REQUEST['sphone']);
$s->bindValue(':location', $_REQUEST['location']);
$s->bindValue(':city', $_REQUEST['city']);
$s->execute();
}
header('location: ../'.$_REQUEST['category']);
請告訴我,我要去哪裏錯了
'接入到.. SET'真的嗎?我認爲這不是標準,但可以使用程序 –