mysql - php not sending messages to databses -


i'm sure it's stupid mistake i've made somewhere, , can't find answer anywhere. i'm trying send new insert query database. connects reason doesn't update fields on database. syntax error in query? tried can think of, please help!

<?php      $first_name = $_post['first_name'];     $last_name = $_post['last_name'];     $email = $_post['email'];     $username = $_post['username'];     $timestamp = time();     $crypt = crypt($_post['password'], $timestamp);      $sql = "insert `dvds`.`users` (`email`, `username`, `first_name`, `last_name`, `password`, `timestamp`) values (" . $email . ", " . $username . ", " . $first_name . ", " . $last_name . ", " . $crypt . ", " . $timestamp . ")";      $con=mysqli_connect("localhost","root","","dvds");      if (mysqli_connect_errno()){       echo "failed connect mysql: " . mysqli_connect_error();     }     else{         mysqli_query($con, $sql);     }      mysqli_close($con);  ?> 

cheers.

you need single quotes around values inserting:

$sql = "insert `dvds`.`users` (`email`, `username`, `first_name`, `last_name`, `password`, `timestamp`) values ('" . $email . "', '" . $username . "', '" . $first_name . "', '" . $last_name . "', '" . $crypt . "', '" . $timestamp . ")'"; 

you should sql injection , how prevent, have significant vulnerability there.

you may consider using timestamp field type in mysql rather unix timestamp.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -