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);
?>

Recommended Answers

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).

Jump to Post

All 2 Replies

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).

hi pritaeas
Solved

Thanks

.....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.