這是一個代碼,用於註冊一個小組的負責人,然後是他的合夥人。爲什麼SQLSTATE [HY000]:一般錯誤?
<?
session_start();
require_once('db.php');
$db = new DB();
$db->newHead($_POST['fname'], $_POST['lname'], $_POST['school'], $_POST['day'], $_POST['month'], $_POST['year'], $_POST['email']);
$hId = $db->getId($_POST['email'], 1);
if ($_POST['pnum'] === 1)
{
$db->newPartner($hId, $_POST['fname1'], $_POST['lname1'], $_POST['day1'], $_POST['month1'], $POST['year1'], $_POST['email1']);
$pId = getId($_POST['email1'], 0);
$db->setHeadId($hId, $pId, 1);
}
if ($_POST['pnum'] === 2)
{
$db->newPartner($hId, $_POST['fname1'], $_POST['lname1'], $_POST['day1'], $_POST['month1'], $POST['year1'], $_POST['email1']);
$p1Id = getId($_POST['email1'], 0);
$db->setHeadId($hId, $p1Id, 1);
$db->newPartner($hId, $_POST['fname2'], $_POST['lname2'], $_POST['day2'], $_POST['month2'], $POST['year2'], $_POST['email2']);
$p2Id = getId($_POST['email2'], 0);
$db->setHeadId($hId, $p2Id, 2);
}
header("Location:Register.php");
?>
,這是db.php中的一部分:
public function getId($email, $type)
{
if ($type)
$query = "SELECT * FROM t_head where h_email = '$email';";
else
$query = "SELECT * FROM t_partner where p_email = '$email';";
return $this->query($query);
}
public function newPartner($hId, $fname, $lname, $day, $month, $year, $email)
{
$query = "INSERT INTO t_partner (p_headid, p_fname, p_lname, p_day, p_month, p_year, p_email)
VALUES ('$hId', '$fname', '$lname', '$day', '$month', '$year', '$email');";
return $this->query($query);
}
public function newHead($fname, $lname, $hschool, $day, $month, $year, $email)
{
$query = "INSERT INTO t_head (h_fname, h_lname, h_school, h_day, h_month, h_year, h_email)
VALUES('$fname', '$lname', '$hschool', '$day', '$month', '$year', '$email');";
return $this->query($query);
}
public function setHeadId($hId, $pId, $num)
{
if ($num === 1)
$query = "UPDATE t_head SET h_p1 = '$pId' WHERE h_id = '$hId';";
else
$query = "UPDATE t_head SET h_p2 = '$pId' WHERE h_id = '$hId';";
$this->execute($query);
}
什麼問題? DB是與PDO一起工作的類。 (我不知道這是什麼!但我總是複製它,然後我在它的底部編寫函數,它始終正常工作。)但知道這個錯誤是什麼意思?
對不起,如果我粘貼了所有的代碼!我不知道
SQLSTATE[HY000]: General error
與哪個部分有關,所以我不能爲你粘貼任何特定的部分/功能。爲了某種目的,我的網站被複制到另一臺服務器,並在3小時前更改了DNS。如果這個細節可以幫助你... ...
什麼是完整(mysql)的錯誤信息? – 2012-04-17 21:42:29
問題是,該消息只是這個短的錯誤:SQLSTATE [HY000]:一般錯誤。 – 2012-04-17 21:45:04
http://php.net/manual/en/function.mysql-error.php – 2012-04-17 22:05:40