Jump to content

unexpected T_LOGICAL


bford21

Recommended Posts

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.

 

 

Link to comment
https://forums.phpfreaks.com/topic/208306-unexpected-t_logical/
Share on other sites

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.

 

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.