PHP code submitting to MySQL isn't working -


i have been tying figure out wrong long time, cannot figure out. have been trying connect local mysql database. when run this, no error thrown. also, know database , table exist, , know username , password correct.

<?php  // connects database  $con = mysqli_connect("localhost", "**my_username**", "**my_password**", "gamesite_data") or die(mysql_error());  $username = $_post["username"]; $password = $_post["password"]; $first_name = $_post["first_name"]; $last_name = $_post["last_name"]; $age = $_post["age"];  mysqli_query($con, "insert information (`username`, `password`, `first_name`, `last_name`, `age`) values ($username, $password, $firstname, $last_name, $age);" ); ?>  <?php mysqli_close($con) ?> 

if values of username, password, first_name, last_name strings, have surround them single quotes here:

mysqli_query($con, "insert information (`username`, `password`, `first_name`, `last_name`, `age`) values ('".$username."', '".$password."', '".$firstname."', '".$last_name."', ".$age.")"); 

and if use mysqli_connect, have use mysqli_error instead of mysql_error.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -