如何将查询插入到插入数据查询中?在PHP中

时间:2018-08-04 21:57:10

标签: php mysql sql

我有此错误:Recoverable致命错误:第20行的C:\ xampp \ htdocs \ freshdelivery \ singup.php中无法将类mysqli_result的对象转换为字符串

我需要在用户表中放置变量costo

代码:

<?php

include 'config.php';

$fname = $_POST["nombre"];
$lname = $_POST["apellido"];
$address = $_POST["direccion"];
$city = $_POST["ciudad"];
$pin = $_POST["codigo"];
$email = $_POST["email"];
$pwd = $_POST["password"];



$costo = $mysqli->query("SELECT costoenvio.id FROM costoenvio WHERE costoenvio.ciudad = '$city' ");




if($mysqli->query("INSERT INTO users (nombre, apellido, direccion, ciudad, codigo, email, password, costo_id) VALUES('$fname', '$lname', '$address', '$city', $pin, '$email', '$pwd', $costo)")){
    echo 'Data inserted';
    echo '<br/>';
}

header ("location:login.php");

?>

0 个答案:

没有答案