...

View Full Version : Error with email registration



Damien118
08-23-2011, 04:14 AM
How is every doing? I'm working on an email registration script, final thought I was done, but I keep getting this error read out:


Error: 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 '' at line 5

Here is a bit of my code:


<?php

mysql_connect("localhost", "USERNAME", "PASSWORD") or die("Could not connect to database");

mysql_select_db("email") or die(mysql_error());

if ($_POST['form_submitted'] == '1') {
## The form was submitted, the user is registering.

$activationKey = mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand();

$username = mysql_real_escape_string($_POST["username"]);
$password = mysql_real_escape_string($_POST["password"]);
$email = mysql_real_escape_string($_POST["email"]);


I think it is referring to my
mysql_select_db("email") or die(mysql_error()); I don't see anything wrong with the line, but then again I'm a newbie to php. Does anyone know why I am getting this error and how I can fix it?

Thank you for your help!

JamesOxford
08-23-2011, 07:17 AM
it isn't referring to the line you think it is. It is referring to your SQL statement. Could you post that? I can already tell you though, that there is probably a problem with the way it is quoted and escaped.

Damien118
08-23-2011, 07:45 AM
it isn't referring to the line you think it is. It is referring to your SQL statement. Could you post that? I can already tell you though, that there is probably a problem with the way it is quoted and escaped.

Here is my statement:


$sql = "INSERT into users(username, password, email, activationkey, status)

VALUES

('$username', '$password', '$email', 'activationKey', 'verify'";

found my mistake, but I never would have found it without your insight! Thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum