Saturday, 31 August 2013

Inserting Data into MySql from php

Inserting Data into MySql from php

I'm new to php and have been going through tutorials, and have hit a
stump, where I can't seem to find what I'm doing wrong in my code, I
welcome any and all assist, the code below is meant to insert data
previously collected into a table that has those fields outline, in
phpmyadmin:
$SQL = "INSERT INTO users ( 'username', 'password', 'email_address',
'date_of_birth', 'first_name', 'last_name', 'phone', 'address', 'city',
'userlevel') values ('" + $username + "', '" + $password + "', '" +
$email_address + "', '" + $date_of_birth + "', '" + $first_name + "', '"
+ $last_name + "', '" + $phone + "', '" + $address + "', '" + $city + "',
'" + $userlevel + "')";
And then to run that code:
mysql_query($SQL); mysql_close($db_handle); print "Records added to the
database";
I'm not 100% sure whether its the layout or not, for inserting variable
data into MySql, also their is no errors about connecting to the database,
furthermore the print at the end of the function runs, therefore it is not
getting an error and stopping before running the code above.
Once again thank you and all assistance is welcome.

No comments:

Post a Comment