0

hi
I am new in php. I could not insert the data into mysql table. and there is no error prompt Below is my code. Pls help me

<?php
include_once '../inc/header.php';
if (isset($_POST['submit']) && $_POST['submit']  != "" )
    {
        $name = $_POST["name"];
        $address = $_POST["address"];
        $tel = $_POST["tel"];
        $fax = $_POST["fax"];
        $email = $_POST["email"];
        $website = $_POST["website"];
        $type = $_POST["type"];    
        echo $name;
        echo $address;
        echo $tel;
        echo $fax;
        echo $email;
        echo $website;
        echo $type;
        try 
            { 
                $sql="INSERT INTO bk_customer (id,name,address,tel,fax,email,type,website)
                      VALUES ('$name','$address','$tel','$fax','$email','$website','$type')";
                $result = mysqli_query($con,$sql) ; 

            echo 'hi';
            exit();
            } 
        catch (Exception $ex) 
            {
               echo $e->getMessage() . "\n";
               file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
               exit();            
            }
     }
mysqli_close($con);
?>
2
Contributors
2
Replies
15
Views
3 Years
Discussion Span
Last Post by Maideen
1

MySQLi does NOT throw exceptions (PDO does), check the method result. Anyway, remove id from your query and you should be fine (and reverse type and website).

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.