问题描述
这是一个代码,用于注册群组的头,然后注册他的合作伙伴。
This is a code to register the head of a group and then his partner(s).
<?
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的一部分:
and this is part of 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一起使用的类。 (我不知道这是什么,但我总是复制它然后我写的功能,然后它的底部,它总是工作正确。)但是知道这个错误是什么意思?
What's the problem?DB is class that is worked with PDO. (I don't know what's this! but I always copy it then I write the functions at then bottom of it and it always worked correctly.) But know What does this error mean?
-
对不起,如果我粘贴所有的代码!我不知道
SQLSTATE [HY000]:一般错误
与哪个部分相关,因此我无法粘贴任何特定的部分/ func。
Excuse me If I pasted all of the code! I don't know
SQLSTATE[HY000]: General error
is related to which part, so that I couldn't paste any specific part/func for you.
我的网站已复制到另一个服务器,并且DNS在3小时前更改为一个目的。如果这个细节可以帮助你...
My site copied to another server and the DNS was changed near 3 hours ago for a purpose. If this detail can help you ...
推荐答案
类似的几个星期前。我修改它改变了php.ini
It happened to me something similar a few weeks ago. I fixed it changing the php.ini
我改变了
;extension=php_pdo_mysql_mysqlnd.dll
extension=php_pdo_mysql_libmysql.dll
到
extension=php_pdo_mysql_mysqlnd.dll
;extension=php_pdo_mysql_libmysql.dll
基本上你改变mysql驱动程序php的用法。我使用xampplite 1.7
basically you change the mysql driver php uses. I used xampplite 1.7
这篇关于为什么是SQLSTATE [HY000]:一般错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!