我正在运行此代码:
$stmt = $pdo_conn->prepare("INSERT into ticket_updates (ticketnumber, notes, datetime, contact_name, contact_email, customer, internal_message, type) values (:ticketnumber, :notes, :datetime, :contact_name, :contact_email, :customer, :internal_message, :type) ");
$stmt->execute(array(':ticketnumber' => $ticketnumber,
':notes' => $TicketSummary,
':datetime' => date("Y-m-d H:i:s"),
':contact_name' => $Ticket_ContactName,
':contact_email' => $Ticket_ContactEmail,
':customer' => 'Y',
':internal_message' => 'N',
':type' => 'update'));
所有表格列都存在并且正确,但还没有超过这一点
我尝试了 var_dump($stmt);
但什么也没得到
最佳答案
使用以下内容验证连接是否正确建立
try
{
$dbh = new PDO("mysql:host=xxxxxxxxxxxx;dbname=streaming", "xxxx", "xxxx");
}
catch (Exception $e)
{
throw new Exception( 'Something really gone wrong', 0, $e);
}
像这样执行时也可以输出错误
$sth->execute() or die(print_r($sth->errorInfo(), true));
最后,您可能还需要在页面上启用错误,因此请将其放置在页面标题中,如果是单个页面,则将其放置在最顶部:
error_reporting(-1);
负1表示它将打印所有错误。
在您发现错误之前,很难进一步诊断问题,但问题可能归结为与数据库的连接或您如何形成参数数组。
关于php - PDO 插入 SQL 未执行且没有错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27168597/