我在下面有一个代码......有时这段代码只是告诉我一切正常,以及"成功"味精。但插入的新行未添加到数据库中。 我想:echo $ this-> mysqli->错误;会给我错误,但它不起作用?
if ($stmt = $this->mysqli->prepare("INSERT INTO tournaments ("
. "id_system, "
. "id_rank_admin, "
. "id_tournament_class, "
. "id_season, "
. "tournament_name,"
. "description,"
. "city,"
. "address,"
. "tournament_date,"
. "start_time,"
. "entry_fee,"
. "tournament_type,"
. "accepted_expansions,"
. "prices,"
. "additional_info,"
. "status,"
. "organizer_name,"
. "organizer_logo,"
. "organizer_link) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "))
{
$stmt->bind_param("sssssssssssssssssss",
$this->id_system,
$this->id_rank_admin,
$this->it_tournament_class,
$this->id_season,
$this->tournament_name,
$this->description,
$this->city,
$this->address,
$this->tournament_date,
$this->start_time,
$this->entry_fee,
$this->tournament_type,
$this->accepted_expansions,
$this->prices,
$this->additional_info,
$this->status,
$this->organizer_name,
$this->organizer_logo,
$this->organizer_link);
$stmt->execute();
$stmt->close();
}
else
{
echo $this->mysqli->error;
}
答案 0 :(得分:1)
$ok=$stmt->execute();
if($ok)
{
echo "Query Executed Successfully";
}
else
{
echo(mysqli_error($link));
}
mysqli->执行它所做的是基于它返回true或false你可以得到你的错误我没有太多的mysqli oop方式所以如果任何语法错误纠正它
答案 1 :(得分:0)
我在这里找到了这个:http://php.net/manual/en/mysqli.error.php
string mysqli_error ( mysqli $link )
返回最近可以成功或失败的MySQLi函数调用的最后一条错误消息。
可能会让您更好地了解错误的位置。
答案 2 :(得分:0)
试试这个:
$link = mysqli_connect("localhost", "my_user", "my_password", "db");
else
{
echo(mysqli_error($link));
}