PHP Mysql PDO 绑定变量数量与令牌数量不匹配

时间:2023-04-08
本文介绍了PHP Mysql PDO 绑定变量数量与令牌数量不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我环顾四周,但似乎无法找到我的问题的答案.

这是我第一次使用 PDO,所以我完全是新手.

我将大量数据拆分为 2 个表并希望将它们合并为一个,还有其他方法可以做到这一点,但没有深入探讨为什么我要这样做的复杂原因...

我生成了我想从中复制数据的表的记录集

构建我的语句

循环运行

但我收到以下错误

SQLSTATE[HY093]: Invalid parameter number: number of bound variables not match of tokens

我已经通过并三重检查了我有相同数量的变量,所以为什么令牌不匹配我不知道"就像我说的那样对此很陌生,所以可能错过了专业人士认为显而易见的东西.

  • 可能值得一提的是,我没有添加到表中的每一列,还有其他列,但我已将它们排除在准备好的语句之外...这是我的代码:

    //$dbh = new PDO($hostname_Seriously, $DB_USER, $DB_PASSWORD);$dbh = new PDO('mysql:host=localhost;dbname=seriouslysoulful_summers', $username_Seriously, $password_Seriously);$stmt = $dbh->prepare("INSERT INTO records_rec (oldid_rec, firstname_rec,artist_rec,side_rec,bside_rec,label_rec,condition_rec,genere_rec,price_rec,collection_rec,active_rec,info_rec,notes_rec,order_rec,alabelimage_rec,asound_rec_rec,b、featured_rec、format_rec)VALUES (:oldid_rec, :firstname_rec, :artist_rec, :aside_rec, :bside_rec, :label_rec, :condition_rec, :genere_rec, :price_rec, :collection_rec, :active_rec, :info_rec, :notes_rec, :order_image_rec_recasound_rec, bsound_rec, :featured_rec, :format_rec)");$stmt->bindParam(':oldid_rec', $id);$stmt->bindParam(':firstname_rec', $firstname);$stmt->bindParam(':artist_rec', $artist);$stmt->bindParam(':aside_rec',$aside);$stmt->bindParam(':bside_rec',$bside);$stmt->bindParam(':label_rec',$label);$stmt->bindParam(':condition_rec',$condition);$stmt->bindParam(':genere_rec',$genere);$stmt->bindParam(':price_rec',$price);$stmt->bindParam(':collection_rec',$collection);$stmt->bindParam(':active_rec',$active);$stmt->bindParam(':info_rec',$info);$stmt->bindParam(':notes_rec',$notes);$stmt->bindParam(':order_rec',$order);$stmt->bindParam(':alabelimage_rec',$alabel);$stmt->bindParam(':blabelimage_rec',$blabel);$stmt->bindParam(':asound_rec',$asound);$stmt->bindParam(':bsound_rec',$bsound);$stmt->bindParam(':featured_rec',$featured);$stmt->bindParam(':format_rec',$format);$reccount = 0;//做{$id = $row_rs_original['id_prod'];$名字=mysql_real_escape_string($row_rs_original['firstname_prod']);$artist = mysql_real_escape_string($row_rs_original['artist_prod']);$aside = mysql_real_escape_string($row_rs_original['a_side_prod']);$bside = mysql_real_escape_string($row_rs_original['b_side_prod']);$label = mysql_real_escape_string($row_rs_original['label_prod']);$condition = mysql_real_escape_string($row_rs_original['condition_prod']);$genere = $row_rs_original['genre_prod'];$price = $row_rs_original['price_prod'];$collection = mysql_real_escape_string($row_rs_original['collection_prod']);$active = $row_rs_original['active_prod'];$info = mysql_real_escape_string($row_rs_original['info_prod']);$notes = mysql_real_escape_string($row_rs_original['notes_prod']);$order = $row_rs_original['order_prod'];$alabel = mysql_real_escape_string($row_rs_original['labelimage_A_prod']);$blabel = mysql_real_escape_string($row_rs_original['labelimage_B_prod']);$asound = mysql_real_escape_string($row_rs_original['soundfile_A_prod']);$bsound = mysql_real_escape_string($row_rs_original['soundfile_B_prod']);$featured = $row_rs_original['featured_prod'];$format = $row_rs_original['format_prod'];$stmt->execute();$reccount = $reccount +1;/