SQL不正确的整数值
我正在尝试解决以下列出的以下错误。我做了一个var_dump,以确保值(int(15))与期望:一个int; B:不空/空; C:正确的期望值。我的测试未能解决该问题,只有在我理解的持续存在的情况下将其识别。
我希望有人可以进一步向我解释这个问题并提供指导,以便我可以解决我认为是一个简单的错误,但我无法解决此错误。我整夜大部分时间都尝试解决此错误。我已经搜索了Stackoverflow,CodeAcademy,Google Google等。我还没有找到可以帮助我解决此错误的答案。感谢您的帮助。
问题:插入语句失败
确定的问题:第一个INT给定($ threadID
) - int(15)的期望值为'15'
var_dump: int(15)#correct
错误(short)
常规错误:1366不正确的整数值:'pt_threadid'for column'pt_threadid'在第1行
错误(FULL)
致命错误:未被发现的pDoexception:sqlstate [hy000]:一般错误:1366不正确的整数值:in/applications/mamp/htdocs/mccuv222222222222222222222222222222222222222222222222222222222222太体/堆栈跟踪:#0/Applications/mamp/htdocs/mcuv22/is_forum/process.php(1196):pdostatement-> execute()#1/applications/mamp/htdocs/mamp/htdocs/mccuv22222222222222222222222222222222222222222222222222222222222222222222222222222UR ReplyAdd(对象(PDO),15、35、0、0、21、78、0,'',0、0、0、0、0、0、0、0、0,'i“ m示例测试... ','测试副本是...','Bosto ...',0,0,“完成”,“场景”,“ open”,“ lose”,“中等”,“中等”,“ ic”,0,0,0, 1,1,'nyc',“地标”,'',“城堡摇滚,明尼苏达州...”,“地址为Opti ...','Spertn',-65,“洪水”,3 | 3 |。 ',' 18','15:06:38','15:06:38')#2 {main}在/applications/mamp/htdocs/mcuv22/is_forum/process.php中扔进了1196
>
代码:
var_dump($threadID) == int(15)# correct expected value
#build string for SQL insert with replacement vars, ?
$sql = "
INSERT INTO `frm_POST`
(
`pt_threadID`
)VALUES(
:pt_threadID
)
;";
# $statement->bindValue(':threadID', "$threadID");
# addition bind values removed for brevity to focus on issue
# tested statement as given above, same error persists
# Prepare our statement using the SQL query.
$statement = $db->prepare($sql);
$statement->bindValue(':pt_threadID', "pt_threadID");
//Execute the statement and insert our values.
$inserted = $statement->execute();
//clear - free up connection
unset($statement, $db);//clear
I am trying to resolve the following error as listed below. I have done a var_dump to ensure the value (int(15)) is as expect A: An int; B: not empty/null; C: correct expected value. My tests have failed to resolve the issue, only identify it as I understand it to persist.
I am hoping someone can further explain the issue to me and provide guidance so that I can resolve what I thought was a simple error, but I am unable to resolve this error. I have tried for most of the night to resolve this error. I have searched StackOverflow, CodeAcademy, Googled, etc. I have not found an answer that can help me to resolve this error. Thank you for your help.
Problem: insert statement fails
Issue identified: first int given ($threadID
) - expected value for int(15) is '15'
var_dump: int(15) #correct
Error (short)
General error: 1366 Incorrect integer value: 'pt_threadID' for column 'pt_threadID' at row 1
Error (full)
Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'pt_threadID' for column 'pt_threadID' at row 1 in /Applications/MAMP/htdocs/MCUv22/is_forum/process.php:1196 Stack trace: #0 /Applications/MAMP/htdocs/MCUv22/is_forum/process.php(1196): PDOStatement->execute() #1 /Applications/MAMP/htdocs/MCUv22/is_forum/process.php(422): replyADD(Object(PDO), 15, 35, 0, 0, 21, 78, 0, '', 0, 0, 0, 0, 0, 0, 0, 0, 'I"m an example test...', 'test copy is ...', 'shitty of bosto...', 0, 0, 'finished', 'scene', 'open', 'loose', 'moderate', 'ic', 0, 1, 1, 'NYC', 'a landmark', '', 'Castle Rock, Mn...', 'address is opti...', 'afternoon', -65, 'flood', '3 | 3 | 3', 0, 1, 2, 1, 1, 1, 1, 1, 1, 0, '', NULL, NULL, 'a:2:{i:0;s:6:"m...', 'a:2:{i:0;s:11:"...', 'X, Bobby Belche...', '', 99, '2013-12-18', '2013-12-18', '15:06:38', '15:06:38') #2 {main} thrown in /Applications/MAMP/htdocs/MCUv22/is_forum/process.php on line 1196
Code:
var_dump($threadID) == int(15)# correct expected value
#build string for SQL insert with replacement vars, ?
$sql = "
INSERT INTO `frm_POST`
(
`pt_threadID`
)VALUES(
:pt_threadID
)
;";
# $statement->bindValue(':threadID', "$threadID");
# addition bind values removed for brevity to focus on issue
# tested statement as given above, same error persists
# Prepare our statement using the SQL query.
$statement = $db->prepare($sql);
$statement->bindValue(':pt_threadID', "pt_threadID");
//Execute the statement and insert our values.
$inserted = $statement->execute();
//clear - free up connection
unset($statement, $db);//clear
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论