mysqli语句出错,选择并更新

时间:2017-11-21 20:12:38

标签: php mysql mysqli

您好我在使用select语句时遇到问题,mysqli_prepare返回一个布尔值。我得到了回复#34; mysqli_stmt_bind_param()期望参数1为mysqli_stmt,boolean given"  我有一个类似的代码,所以我无法找到我的错误。这是我的代码:

$mailUser = $_POST["mailUser"];

$statement = mysqli_prepare($con, "SELECT store.name, product.name, location.hall, location.price FROM location INNER JOIN product ON product.id = location.idProduct INNER JOIN store ON store.id=location.idStore WHERE mailUser= ?");

mysqli_stmt_bind_param($statement, "s", $mailUser);

mysqli_stmt_execute($statement);

另外,我正在尝试使用php变量更新值,它没有显示任何错误,但值没有更新

$statement = mysqli_prepare($con, "UPDATE product SET description='.$description.', brand='.$brand.', altBrand='.$altBrand.', quant='.$quant.', quantToday='.$quantToday.' WHERE name='.$name.' AND mailUser='.$mailUser.'");

mysqli_stmt_execute($statement);

--- --- EDIT 我设法通过将代码更改为此来解决第二个问题:

$ statement = mysqli_prepare($ con," UPDATE product SET description = ?, brand = ?, altBrand = ?, quant = ?, quantToday =?WHERE mailUser =?and name =?") ;     mysqli_stmt_bind_param($ statement," sssssss",$ description,$ brand,$ altBrand,$ quant,$ quantToday,$ mailUser,$ name);     mysqli_stmt_execute($语句);

0 个答案:

没有答案