Jump to content
MakeWebGames

Query Error - Email Validation


Saint
 Share

Recommended Posts

Hi when i installed the "[V2] Email Activation" from this website, i did exactly what it said i even added teh sql it told me and i still get this error.

QUERY 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 1

Query was INSERT INTO users (username, login_name, userpass, level, money, crystals, donatordays, user_level, energy, maxenergy, will, maxwill, brave, maxbrave, hp, maxhp, location, gender, signedup, email, bankmoney, lastip, lastip_signup) VALUES( '1234', '1234', md5('567'), 1, 100, 0, 0, 1, 12, 12, 100, 100, 5, 5, 100, 100, 1, 'Male', unix_timestamp(), '[email protected]', -1, '55.555.53.51', '51.555.95.84', random_string('alnum', 32)

 

 

Can Anybody help???

Link to comment
Share on other sites

Re: Query Error - Email Validation

Hereis the insertQuery and Script =D

 

$db->query("INSERT INTO users (username, login_name, userpass, level, money, crystals, donatordays, user_level, energy, maxenergy, will, maxwill, brave, maxbrave, hp, maxhp, location, gender, signedup, email, bankmoney, lastip, lastip_signup) VALUES( '{$username}', '{$username}', md5('{$_POST['password']}'), 1, $sm, 0, 0, 1, 12, 12, 100, 100, 5, 5, 100, 100, 1, '{$_POST['gender']}', unix_timestamp(), '{$_POST['email']}', -1, '$IP', '$IP', random_string('alnum', 32)");
$i=$db->insert_id();
// get data just entered
$getUser = mysql_query("SELECT userid, login_name, email, Random_key FROM users WHERE login_name = '{$username}'") or die(mysql_error());
$row = mysql_fetch_assoc($getUser);
// Send rego email
$stamp = unix_timestamp;
$to = $_POST['email'];
$subject = "Gangstas City Account Activation";
$body = "Hello " . $username . ",\n\nThank you for registering at Gangstas City!\n\nClick this link to activate your account: http://www.gangstas-city.com/activate.php?ID=".$row['userid']."&key=".$row['Random_key']." \n\n -Saint";
$headers = "From: [email][email protected][/email]\r\n";
if (mail($to, $subject, $body, $headers)) {}
$db->query("INSERT INTO userstats VALUES($i, 10, 10, 10, 10, 10, 10)");
Link to comment
Share on other sites

Re: Query Error - Email Validation

 

what is the random_string('alnum', 32) for? there is no column for it in the query

I dont know why it is there, search for [V2] Email Activation in the search and click on the link, the instructions on how to install are not clear and it tells me to add that in the place i have shown you, it also asked me to add sql under the named "activation" and "random_key" I thought that the problem is the fact that the sql was wrong so i added an sql under the name "random_string" but it still did not work.

Link to comment
Share on other sites

Re: Query Error - Email Validation

Also the Random_string links to the rfunctions.php file which has this code at the top of the page so im guessing that this is where the random codeis generated.

 

<?php
function random_string($type = 'alnum', $len = 8)
{			

 

And for that to function, i added "include rfunctions.php" at the top of my register page, but still no success and getting that same error i posted before.

I BEG!! Somebody please help :/

Much Appritiated

In addition to last post i now have to edit this becasue i forgot to say i have updated my insert query so now there is a column for random_string. Here is my updated Query code

 

$db->query("INSERT INTO users (username, login_name, userpass, level, money, crystals, donatordays, user_level, energy, maxenergy, will, maxwill, brave, maxbrave, hp, maxhp, location, gender, signedup, email, bankmoney, lastip, lastip_signup, Random_key) VALUES( '{$username}', '{$username}', md5('{$_POST['password']}'), 1, $sm, 0, 0, 1, 12, 12, 100, 100, 5, 5, 100, 100, 1, '{$_POST['gender']}', unix_timestamp(), '{$_POST['email']}', -1, '$IP', '$IP', random_string('alnum', 32)");
$i=$db->insert_id();
// get data just entered
$getUser = mysql_query("SELECT userid, login_name, email, Random_key FROM users WHERE login_name = '{$username}'") or die(mysql_error());
$row = mysql_fetch_assoc($getUser);
// Send rego email
$stamp = unix_timestamp;
$to = $_POST['email'];
$subject = "Gangstas City Account Activation";
$body = "Hello " . $username . ",\n\nThank you for registering at Gangstas City!\n\nClick this link to activate your account: http://www.gangstas-city.com/activate.php?ID=".$row['userid']."&key=".$row['Random_key']." \n\n -Saint";
$headers = "From: [email][email protected][/email]\r\n";
if (mail($to, $subject, $body, $headers)) {}

 

Sorry if you think that im flooding this page full of posts but i am trying my upmost hardest to give u as much nformation as possible so you have an understanding of what i have done.

Link to comment
Share on other sites

Re: Query Error - Email Validation

Thanks To Floydian i now have that query error fixed!! He is a legend haha. But nowi have anotherprolem haha its one after another withthis haha, it seems that i havnt been all the code for the email verification to function properly, when i go to email and click on theactivation link it says youare activated but when i try to log into teh game it says you have not activated, im guessingthat this is missing something that inserts into the sql to say you have activated or maybe it is missing an "if" "else" command to say if activated = 1 thenlogs you in :/

Link to comment
Share on other sites

Re: Query Error - Email Validation

Thanks To Floydian i now have that query error fixed!! He is a legend haha. But nowi have anotherprolem haha its one after another withthis haha, it seems that i havnt been all the code for the email verification to function properly, when i go to email and click on theactivation link it says youare activated but when i try to log into teh game it says you have not activated, im guessingthat this is missing something that inserts into the sql to say you have activated or maybe it is missing an "if" "else" command to say if activated = 1 thenlogs you in :/

Link to comment
Share on other sites

Re: Query Error - Email Validation

Thank You everybody for your support with this problem, thanks to everybody who helped, upmost respect to Templar and Floydian for between them sorting this whole problem out. They truely are amazing coders

 

POST CLOSED!!!

Link to comment
Share on other sites

Re: Query Error - Email Validation

Huh...Im having the same problem where I cant log into the game. It DOES insert into the database but I cant seem to find where to put the

if ($mem['activated'] ==0)
{
die("Your account is not active, check your email address including junk boxes.
[url='login.php']back[/url]");
}

.

I dont even know if thats right. I manyally added a 1 into the data base and cant log in ANY account. Does say the accounts ARE already activated though.

Any thoughts?

How did you get that fixed Saint?

lol

Link to comment
Share on other sites

Re: Query Error - Email Validation

After:

 

'{$_POST['email']}', -1, '$IP', '$IP', '1', md5(unix_timestamp()))");

 

Add this instead:

 

md5(unix_timestamp()))");

 

Make sure the query above this has Random_key in it so it looks like this

 

$db->query("INSERT INTO users 
	(username, login_name, userpass, level, money, crystals, donatordays, user_level,
	energy, maxenergy, will, maxwill, brave, maxbrave, hp, maxhp, location, gender, 
	signedup, email, bankmoney, lastip, lastip_signup, new_mail, Random_key)

 

see if that helps...

Link to comment
Share on other sites

Re: Query Error - Email Validation

Well...I noticed Random_key was missing and I added that earlier....I dont know what new_mail is for though. I dont have that in my DB or know what its for. Also Im kinda unclear on your instructions....Add

md5(unix_timestamp()))");

after

'{$_POST['email']}', -1, '$IP', '$IP', '1', md5(unix_timestamp()))");

???

Isnt that kinda doubling up on the

md5(unix_timestamp()))");

?

And is the

random_string('alnum', 32)

not needed anymore?

Sorry for the ignorance...Im still kinda new at this.

Link to comment
Share on other sites

Re: Query Error - Email Validation

Oh sorryi meant in stead of using the Random_string, use this code instead md5(unix_timestamp()))");

Also that New_Mail is notseeded in your code that is something else which i use in my codes, that was just an example of what yours should look like without the new_mail

Link to comment
Share on other sites

Re: Query Error - Email Validation

Nope. once again It is the same as before...I click the link...it adds the "1" to my database and says thanx for valadating...now go here to log in...I try and log in and it tells me go validate. Does that with ALL the accounts. I still think its in the authenticate.php where I put the

if ($mem['activated'] == 0)
{
die("Your account is not active, check your email address including junk boxes.
[url='login.php']back[/url]");
}

 

But once again I cant figure out exactly where that goes.

Link to comment
Share on other sites

Re: Query Error - Email Validation

GOT IT!!! =o)

Ok...heres what I did...Like I said my system actually sent the email with the link...worked with both the

md5(unix_timestamp()))");

and the

random_string('alnum', 32)

way btw so pick one.

You click the link and it DID change the 0 to a 1 in the database but I couldnt log anyone in.

I opened up HEADER.PHP

and after

$q=$db->query("SELECT u.*,g.* FROM users u LEFT JOIN gangs g ON g.gangID=u.gang WHERE u.userid={$userid}");
$r=$db->fetch_row($q);

I inserted a

if ($ir['activated'] ==0)
{
die("Your account is not active, check your email address including junk boxes.
[url='login.php']back[/url]");
}

 

That seamed to do it. I tested it and nobody can log in without that stupid "1" in the database and anyone who DOES have it WILL log in. I also tested fliping through a couple pages to see if i could access them manually and i couldnt....untill I checked the e-mail and clicked that link and relogged in.

 

YEAY! lol

Thanx everyone for the help. Its been teaching me some things. Now my way might not be the best way or most efficiant way or even the most secure way....but it is a working way right now. Il learn the better ways later. =oD

Thanx again!

Link to comment
Share on other sites

  • 1 year later...

maybe it is a little late for the reply...but i just used the mod...the reason why even if activate is 1 it doesnt loggin the user is because there is a missing "" in authenticate.php :

Wrong

if ($ir['activated'] ==0)
{
die("Your account is not active, check your email address including junk boxes.
[url='login.php']back[/url]");
}

 

Right

if ($ir['activated'] =="0")
{
die("Your account is not active, check your email address including junk boxes.
[url='login.php']back[/url]");
}

 

Thanks

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

 Share

×
×
  • Create New...