可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
The error occurs on line 42:
$result->bind_param("ssssisssss", $Firma, $Partner, $Abteilung, $Strasse, $PLZ, $Ort, $Telefon, $Email, $Website, $Info );
This is the whole prepared statement:
$sql = "INSERT INTO `firmen` (`Firma`, `Ansprechpartner`, `Abteilung`, `Strasse`, `PLZ`, `Ort`, `Telefon`, `Email`, `Website`, `Zusatzinfos`)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$result = $db->prepare( $sql );
$result->bind_param("ssssisssss", $Firma, $Partner, $Abteilung, $Strasse, $PLZ, $Ort, $Telefon, $Email, $Website, $Info );
$result->execute();
I can't find the mistake, I already read almost every question with the same mistake an I also compared my Code with a lot of Tutorial and it looks exactly the same...
Thanks in advance!
回答1:
...usually this occurs when you have an error in prepare statement,
It might happen that you have a typo in sql prepare. to verify that.
check the error with this
$stmt = $this->db->prepare("INSERT INTO ".TB_ADMINISTRATION."(name, password, email) VALUES (?, ?, ?)");
if(!$stmt) //if there is an error, then it will be shown!.
{ // show error
echo $this->db->error;
} else {
// everything is good to go !.
}
回答2:
one extra parameters so i removed first parameter:
change the following
$result->bind_param("ssssisssss", $Firma, $Partner, $Abteilung, $Strasse, $PLZ, $Ort, $Telefon, $Email, $Website, $Info );
with
$result->bind_param($Firma, $Partner, $Abteilung, $Strasse, $PLZ, $Ort, $Telefon, $Email, $Website, $Info );
回答3:
Here you have you have 10 value in the insert statement
$sql = "INSERT INTO `firmen` (`Firma`, `Ansprechpartner`, `Abteilung`, `Strasse`, `PLZ`, `Ort`, `Telefon`, `Email`, `Website`, `Zusatzinfos`)
and you are giving 11 parameters in the bind->param()
like this
$result->bind_param("ssssisssss", $Firma, $Partner, $Abteilung, $Strasse, $PLZ, $Ort, $Telefon, $Email, $Website, $Info );
So you have to corret the number of arguments. So either add another column in the insert statement or remove one value from the bind->param()
and keep your insert statement as it is.
回答4:
As the error-message says, $result
seems to be not an object. try to debug this by using var_dump($result);
right after your prepare-call.
It looks like you're using PHP's PDO. In that case, take a look at the documentation.
If the database server successfully prepares the statement, PDO::prepare() returns a PDOStatement object. If the database server cannot successfully prepare the statement, PDO::prepare() returns FALSE or emits PDOException (depending on error handling).
ALso, what is "sisssssss"?
10 values are needed and you insert 11.
Hm, change this query:
$sql = "INSERT INTO `firmen` (`Firma`, `Ansprechpartner`, `Abteilung`, `Strasse`, `PLZ`, `Ort`, `Telefon`, `Email`, `Website`, `Zusatzinfos`)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
Into this:
$sql = "INSERT INTO firmen ('Firma', 'Ansprechpartner', 'Abteilung', 'Strasse', 'PLZ', 'Ort', 'Telefon', 'Email', 'Website', 'Zusatzinfos')
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
This one '
and ` are not the same.
回答5:
Your error is in the below code
$sql = "INSERT INTO firmen
(Firma
, Ansprechpartner
, Abteilung
, Strasse
, PLZ
, Ort
, Telefon
, Email
, Website
, Zusatzinfos
)
delete the apostrophe ('') from each as
$sql = "INSERT INTO firmen (Firma, Ansprechpartner, Abteilung, Strasse, PLZ, Ort, Telefon, Email, Website, Zusatzinfos)