nightcrawler Posted June 18, 2007 Share Posted June 18, 2007 $createusername_q = "INSERT INTO checkbook_users ('id', 'username', 'name', 'email', 'password') VALUES ( NULL, " . $_POST['register_username'] . "," . $_POST['register_name'] . "," . $_POST['register_email'] . "," . $_POST['register_password']; $createusername = mysql_query($createusername_q) or die("Couldn't create username."); Not sure what I'm doing wrong, POST Data goes through fine, variable names are correct. I think it's just a quotes issue. Link to comment https://forums.phpfreaks.com/topic/55986-solved-sql-syntax-insert-with-_post-data/ Share on other sites More sharing options...
bubblegum.anarchy Posted June 18, 2007 Share Posted June 18, 2007 yeah, apply mysql_real_escape_string() to each $_POST value and add quotes. ... and the ending paranthesis is missing. Link to comment https://forums.phpfreaks.com/topic/55986-solved-sql-syntax-insert-with-_post-data/#findComment-276564 Share on other sites More sharing options...
nightcrawler Posted June 18, 2007 Author Share Posted June 18, 2007 $createusername_q = "INSERT INTO checkbook_users (id, username, name, email, password) VALUES (NULL, " . mysql_real_escape_string($_POST['register_username']) . "," . mysql_real_escape_string($_POST['register_name']) . "," . mysql_real_escape_string($_POST['register_email']) . "," . mysql_real_escape_string($_POST['register_password']) . ")"; How's that look? it's still not working. Link to comment https://forums.phpfreaks.com/topic/55986-solved-sql-syntax-insert-with-_post-data/#findComment-276790 Share on other sites More sharing options...
nightcrawler Posted June 18, 2007 Author Share Posted June 18, 2007 $register_username = $_POST['register_username']; $register_name = $_POST['register_name']; $register_email = $_POST['register_email']; $register_pw = $_POST['register_password']; $createusername_q = "INSERT INTO checkbook_users (id, username, name, email, password) VALUES (NULL, '$register_username', '$register_name', '$register_email', '$register_password')"; This resolved the issue. I'll mark as solved Link to comment https://forums.phpfreaks.com/topic/55986-solved-sql-syntax-insert-with-_post-data/#findComment-277001 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.