echo gettype($mysqli);
$mysqli=mysqli_connect("localhost", "ivanmatiasjr", "igm384062", "OnlineStore");
if(mysqli_connect_error()){printf("Connection failed: %s\n", mysqli_connect_error());exit();}
$cat_id = mysqli_real_escape_string($mysqli, $_SESSION['cat_id']);
$cat_title = mysqli_real_escape_string($mysqli, $_SESSION['cat_title']);
$item_title = mysqli_real_escape_string($mysqli, $_POST['item_title']);
$item_price = mysqli_real_escape_string($mysqli, $_POST['item_price']);
$item_desc = mysqli_real_escape_string($mysqli, $_POST['item_desc']);
$item_image = mysqli_real_escape_string($mysqli, $_POST['item_image']);
$sql = "INSERT INTO store_items (cat_id, item_title, item_price, item_desc, item_image) VALUES ('".$cat_id."', '".$item_title."', '".$item_price."', '".$item_desc."', '".$item_image."')";
$res = mysqli_query($mysqli, $sql) or die(mysqli_error($res));
mysqli_free_result($mysqli);
mysqli_close($mysqli);
错误消息是:
警告:mysqli_error()要求参数1为mysqli,布尔值在第59行的C:\ Program Files(x86)\ Apache Software Foundation \ Apache2.2 \ htdocs \ addItemToCategory.php中给出
第59行是我拥有mysqli_query()
功能的地方。
答案 0 :(得分:0)
mysql_error期望mysqli链接作为参数。您正在发送$ res作为参数。