How to insert Integer value in DB - PHP -


i have using php inserting integer value in database.

iam using this

$postcode = $_post['postcode']; $mysql_user_resultset = mysqli_query($con, "insert user (postcode) values ($postcode)"); 

i have several field in db. name, username, etc. defined varchar, postcode defined int. if not enter value postcode, doesn't insert database

you cast variable int:

$postcode = (int) $_post['postcode']; $mysql_user_resultset = mysqli_query($con, "insert user (postcode) values ($postcode)"); 

note you're not using precautions regarding sql injections, suggest bind parameters before query them, using pdo class.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -