Hi all,
I've made a newsletter subscription system for a website. It takes information from a small form and submits it into two tables in the database, one User table and one Userinfo table. It has always worked so far, but some time ago we moved to another hosting. Now, the script doesn't work properly anymore. I can't be completely sure it's because of the change of hosting, but it soiunds logical.
Anyway; here's the error message and code. I've thoroughly reviewed it and I can't see any mistakes or faulty code. Apparently; something's wrong with the first insertion. I've checked the second insertion and that one does work properly. Since both are the same, I have no idea why the first won't work.
Does anyone have a clue what the problem is? I'd be eternally grateful
.
Error message:
PHP script:
I've made a newsletter subscription system for a website. It takes information from a small form and submits it into two tables in the database, one User table and one Userinfo table. It has always worked so far, but some time ago we moved to another hosting. Now, the script doesn't work properly anymore. I can't be completely sure it's because of the change of hosting, but it soiunds logical.
Anyway; here's the error message and code. I've thoroughly reviewed it and I can't see any mistakes or faulty code. Apparently; something's wrong with the first insertion. I've checked the second insertion and that one does work properly. Since both are the same, I have no idea why the first won't work.
Does anyone have a clue what the problem is? I'd be eternally grateful
Error message:
Code:
Something went wrong. Please try again. You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'User(Username,Password,Permission) VALUES( 'username','080f651e3f
PHP script:
PHP:
// if the required fields have been filled out
if($_POST['form_user'] AND $_POST['form_pass'] AND $_POST['form_email']) {
// if the passwords are equal
if($_POST['form_pass'] == $_POST['form_pass2']) {
// if user not already registered
$q = "SELECT * FROM User WHERE Username = '" . $_POST['form_user'] . "'";
$result = mysql_query($q);
if(mysql_num_rows($result) == 0) {
// insert the user information
$pass = md5($_POST['form_pass']);
$q = "INSERT INTO User(Username,Password,Permission) VALUES(
'" . $_POST['form_user'] . "','" . $pass . "','1'
)";
if(mysql_query($q)) {
$id = mysql_insert_id();
// insert the personal information
$q = "INSERT INTO UserInfo(Name,UserSeq,Email,Country,Format,Newsletter,Promotion,UserType) VALUES(
'" . $_POST['form_name'] . "','" . $id . "','" . $_POST['form_email'] . "','" . $_POST['form_country'] . "',
'" . $_POST['form_format'] . "','" . $_POST['form_newsletter'] . "','" . $_POST['form_promotion'] . "','4'
)";
if(mysql_query($q)) {
// registration went ok. Email is sent.







