bford21 Posted July 20, 2010 Share Posted July 20, 2010 Alright so I am in the middle of creating an email subscription script and I am having trouble storing the users info in my MySQL database. I have no idea why. I've looked things over 100 times and I still cant get it. Heres what my code looks like. // Connect to database // requires Global Functions ratings_db_connect(); mysql_query("INSERT INTO subscriptions (email, confirmation number, verified) VALUES ($email, $confirmation_number, 'no')"); or die(); I know I have a database connection, the problem lies in the mysql_query. I added or die(); to see if my query was actually working and it wasnt. After adding or die(); I keep getting this error. Parse error: syntax error, unexpected T_LOGICAL_OR in /home/a6908618/public_html/subscribe_process_form.php on line 50 That error goes away if I remove or die(); but then still my info doesn't get put into the database. I am sure this is a simple fix and I am just not seeing it. Any help would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/208306-unexpected-t_logical/ Share on other sites More sharing options...
Zane Posted July 20, 2010 Share Posted July 20, 2010 ')"); or die(); You've got one semicolon too many, that's it. Quote Link to comment https://forums.phpfreaks.com/topic/208306-unexpected-t_logical/#findComment-1088643 Share on other sites More sharing options...
bford21 Posted July 20, 2010 Author Share Posted July 20, 2010 ahh see I knew it would be something simple. I fixed the code to look like this. mysql_query("INSERT INTO subscriptions (email, confirmation number, verified) VALUES ($email, $confirmation_number, 'no')") or die('Error'); That gets rid of the error but now I still cant insert the data into the database. Quote Link to comment https://forums.phpfreaks.com/topic/208306-unexpected-t_logical/#findComment-1088645 Share on other sites More sharing options...
Zane Posted July 20, 2010 Share Posted July 20, 2010 I still cant insert the data into the database. This can only mean that you're getting an Error of "Error", ...right? If you use PHP's mysql_error() function you'll get the precise error and then you can tell us exactly what's wrong. mysql_query("INSERT INTO subscriptions (email, confirmation number, verified) VALUES ($email, $confirmation_number, 'no')") or die(mysql_error()); I'll bet you it has something to do with your column named confirmation number. Quote Link to comment https://forums.phpfreaks.com/topic/208306-unexpected-t_logical/#findComment-1088650 Share on other sites More sharing options...
Alex Posted July 20, 2010 Share Posted July 20, 2010 You need to put quotes around data that isn't being inserted into a numeric typed column. mysql_query("INSERT INTO subscriptions (email, confirmation number, verified) VALUES ('$email', $confirmation_number, 'no')") or die('Error'); Depending on the data type, you might need to put quotes around $confirmation_number as well, because the variable name is $confirmation_number I assumed it's being inserted into a column with a numeric data type. Quote Link to comment https://forums.phpfreaks.com/topic/208306-unexpected-t_logical/#findComment-1088653 Share on other sites More sharing options...
bford21 Posted July 20, 2010 Author Share Posted July 20, 2010 Ahh yes it works. Thanks again everyone for your help. Just as I thought it was a few small errors. Thanks again I love this place. Quote Link to comment https://forums.phpfreaks.com/topic/208306-unexpected-t_logical/#findComment-1088662 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.