Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.