Mysqli没有插入数据

时间:2013-09-05 00:46:22

标签: php post mysqli

您好我正在尝试以下代码块,但没有收到错误,但也没有将数据插入数据库。此外,正在发送POST值。

感谢任何帮助:

    if(!empty($firstName) && !empty($lastName) && !empty($cell)){
    $sql = "SELECT * FROM clientInformation WHERE firstName = '$firstName' AND lastName = '$lastName' AND cell = '$cell' LIMIT 1;";

    if(!$result = $con->query($sql)){
        die('There was an error running the query [' . $con->error . ']');  
        }else{

            $numRows = $result->num_rows;


        }

        if($numRows > 0){

            $newResult = $result->fetch_assoc();

        }else{

    $sql = "INSERT INTO clientInformation (firstName, lastName, address, city, zip, phone, cell, state, email) VALUES ('$firstName', '$lastName', '$address', '$city', '$zip', '$phone', '$cell', '$state', '$email');";


            if(!$result = $con->query($sql)){
        die('There was an error running the query [' . $con->error . ']');  
        }

        }       
}

1 个答案:

答案 0 :(得分:0)

$ firstName

后面有一个分号内部值
... VALUES ($firstName; $lastName, ....

用逗号替换此分号,看看它是否有效。