I have used form data that would be passed to a PHP script that ultimately would store the data in a mySQL database. The data has always been string data. I was wondering if I had data on a form that looks like this:
Age: ( The html page and a text field )
and I have defined age in mySQL as a smallint ( -32768 to 32767 )
How do I do the conversion to make sure age is properly formatted so that it can be placed in successfully in age column in the mySQL database?
I am looking for something like:
$age = mysqli_real_escape_string($con, $_POST['age']);
$sql="INSERT INTO Persons (FirstName, LastName, Age)
VALUES ('$firstname', '$lastname', '$age')";
I am using http://www.w3schools.com/php/php_mysql_insert.asp as a guide using the db name, table name and field names.