0
我有2个表分贝:资源ID错误在尝试RIGHT(字符串,整数)时
db: scwdb
Table 1: tblspecies
field: txtSpeciesList (ex: "Maple")
Table 2: tblsplintersbowlinventory
field: txtProductBowlCode (ex: "MapleSpTi12-025")
field: txtProductPrimarySpecies - which is blank, it is the target field to be filled
而且一些PHP MySQL代码:
mysql_select_db("scwdb", $con);
$query = "SELECT * FROM tblspecies";
$species = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($species)){
$wood = $row['txtSpeciesList'];
$seq = mysql_query('SELECT txtProductBowlCode, RIGHT(txtProductBowlCode,6) FROM tblsplintersbowlinventory');
echo "Species: ". $row['txtSpeciesList'];
echo "<br />";
echo "Wood: ". $wood;
echo "<br />";
echo "Seq: ". $seq;
echo "<br />";
基本上我读tblspecies并为每个txtSpeciesList我得到$物种的价值,并通过tblsplintersbowlinventory循环,每当txtProductBowlCode值包括$物种值我更新txtProductPrimarySpecies与该值。
这可以很好地将txtProductPrimarySpecies设置为$ species值 - 但我也想追加txtProductBowlCode的最后6个字符(例如:MapleSpTi12-025产生12-025)并将其追加到$ species值(Mpale),然后用新的组合值(Maple12-025)更新txtProductPrimarySpecies。
这也运行,但我得到以下的输出:
Species: Ash
Wood: Ash
Seq: Resource id #5
它显示的品种,但由于某些原因,
$seq = mysql_query('SELECT txtProductBowlCode, RIGHT(txtProductBowlCode,6) FROM tblsplintersbowlinventory');
代码给了我 “Resource id #5
” 的错误。
我在这里做错了什么?
这给了我:阵列([0] => Ash07-001 [txtProductBowlCode] => Ash07-001 [1] => 07-001 [RIGHT(txtProductBowlCode,6)] => 07-001)种类:灰 木材:灰 Seq:资源ID#5 – Stephen
好吧,我看到它给出的结果是07-001这是正确的,但为什么我仍然得到资源ID#5错误? – Stephen
此外,我应该提到,每当此循环时,资源ID#跳过2 ... – Stephen