0

您好,我正在尝试以下代码块,虽然也没有将数据插入数据库,但没有收到错误。此外,正在发送 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 . ']');  
        }

        }       
}
4

1 回答 1

0

您在 $firstName 之后的值内有一个分号

... VALUES ($firstName; $lastName, ....

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

于 2013-09-05T01:02:56.073 回答