脚本宝典收集整理的这篇文章主要介绍了php – bind_param()似乎不起作用,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
<?PHP $dbhost = 'localhost'; $dbuser = 'user'; $dbpass = 'password'; $db = new MysqLi($dbhost,$dbuser,$dbpass,'images_db'); if($db->connect_errno > 0){ die('Unable to connect to database [' . $db->connect_error . ']'); } else{ echo "Connected to database"; } //filename,mime_tyPE and file_size are columns in the table images $stmt = $db->PRepare("INSERT INTO images (filename,mime_type,file_size) VALUES (?,?,?)"); $string1 = 'string 1'; $string2 = 'string 2'; $stmt->bind_param('ssi',$string1,$string2,123); $stmt->execute(); $stmt->close(); $MysqLi->close(); ?>
当我执行代码时,没有任何东西被添加到MysqL数据库中.但是当我评论出这条线时
$stmt->bind_param('ssi',123);
mysqli_stmt_bind_param
接受变量(通过引用).你不能使用文字.将您的代码更改为
$fileSize = 123; $stmt->bind_param('ssi',$fileSize);
以上是脚本宝典为你收集整理的php – bind_param()似乎不起作用全部内容,希望文章能够帮你解决php – bind_param()似乎不起作用所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。