它必须是最简单的错误,但我没有看到也没有找到它。我的插入语句(php到mysql)无法使用我的变量
我使用值7填充变量$aa_minerid
。 我在插入中使用此变量。 插入总是插入数据库中的一个0(零)从未有7
我把它放在该字段是一个smallint(6)
我试图
VALUES ('$aa_productid')
VALUES ($aa_productid)
VALUES ("$aa_productid")
VALUES ('{$aa_productid}')
VALUES ("{$aa_productid}")
和所有与使用`藏汉 到脚本放在此后。
如果我放在那里:VALUES (7)
它确实工作。
那么我在这个脚本中做了什么错? BTW末回波就显示变量$ aa_productid权值
<?php
/* This php script should transfer data from the aa to the sql database */
// Info coming from aa
$aa_productid = 7 ;
include ("dogs.inc");
$cxn=mysqli_connect($host,$user,$passwd,$dbname);
$query = 'SELECT * FROM `Price` WHERE '
. ' `Time_Stamp`=(select max(`Time_Stamp`) from `Price` where `Product_ID` = \'1\')';
$result=mysqli_query($cxn,$query) or
die("Couldn't execute select query");
$row = mysqli_fetch_row($result);
$aa_price=$row[3] ;
$aa_value = $aa_price * $aa_amount;
// Info ready to go to database
$sqlinsert = 'INSERT INTO Mining (Product_ID)'
. ' VALUES ($aa_productid)' ;
echo $aa_productid;
你记得在最后使用$ sqlinsert运行mysqli_query,对吗? – 2011-02-15 18:24:43