Jump to content


Photo

Ugh. Registration Error.


  • Please log in to reply
20 replies to this topic

#1 ataria

ataria
  • Members
  • PipPipPip
  • Advanced Member
  • 179 posts

Posted 30 September 2006 - 01:49 PM

Whenever I do register ... I go to check the database to see if it entered the username...
and, it never does.
Here is the code :

$sql1 = "INSERT INTO `users` ( `UID` , `username` , `password` , `points` , `IP` , `email` , `fname` , `lname` , `gender` , `age` , `location` , `registered` , `last_login` , `admin` , `orientation` , `ethnic` , `music` , `AIM` , `YIM` , `MSN` ,  ) 
VALUES (

'', '${username}', '{$pw}', '5000', '{$REMOTE_ADDR}', '{$email}', '{$fname}', '{$lname}', '{$gender}', '{$age}', '{$location}', '{$day}', '{$day}', '0', '{$orientation}', '{$ethnic}', '{$music}', '{$AIM}', '{$YIM}', '{$MSN}' );";


	mysql_query("$sql1");

	$sql1;
	print "<center><font class=user>$username</font><br> You have sucessfully registered! ";


anyone know what the problem is !?


Extra Info ; This is only a little piece of the code (the mysql part).
Yes, I am connected to the database.
Yes, the php tags are closed.

<?php
include ("global.php");
ob_start();
extract($_POST);
extract($_GET);
extract($_SERVER);

if ($action == register) {

	if (!$username || !$pw || !$email || !$verpw || !$veremail || !$fname || !$lname) {


		print " <center> One or more fields are empty. ";
exit;
		}
$sql1 = "INSERT INTO `users` ( `UID` , `username` , `password` , `points` , `IP` , `email` , `fname` , `lname` , `gender` , `age` , `location` , `registered` , `last_login` , `admin` , `orientation` , `ethnic` , `music` , `AIM` , `YIM` , `MSN` ,  ) 
VALUES (

'', '${username}', '{$pw}', '5000', '{$REMOTE_ADDR}', '{$email}', '{$fname}', '{$lname}', '{$gender}', '{$age}', '{$location}', '{$day}', '{$day}', '0', '{$orientation}', '{$ethnic}', '{$music}', '{$AIM}', '{$YIM}', '{$MSN}' );";


	mysql_query("$sql1");

	$sql1;
	print "<center><font class=user>$username</font><br> You have sucessfully registered! ";

}

else{

that's the top part.
in the else, is, nothing but echo's with html in it (for the table).


And, I don't get errors when I click register....
it says..
"mike
You have sucessfully registered!"
but, it never does anything...

so, help!!

#2 ataria

ataria
  • Members
  • PipPipPip
  • Advanced Member
  • 179 posts

Posted 30 September 2006 - 02:19 PM

any help!?

#3 bljepp69

bljepp69
  • Members
  • PipPipPip
  • Advanced Member
  • 111 posts
  • LocationSacramento, CA

Posted 30 September 2006 - 02:51 PM

Remove the " from around " $sql1.

so...mysql_query($sql1).


Guru? No, but I do RTFM

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 30 September 2006 - 03:21 PM

Change this:
mysql_query("$sql1");

	$sql1;

to this:
mysql_query("$sql1") or die("Error with query: {$sql1}<br />\n" . mysql_error());


#5 ataria

ataria
  • Members
  • PipPipPip
  • Advanced Member
  • 179 posts

Posted 30 September 2006 - 03:36 PM

Parse error: syntax error, unexpected T_VARIABLE in /home/ataria/public_html/preview.php on line 25

I get that when i do the first one...

and, i get an error with the second one... :(

#6 ataria

ataria
  • Members
  • PipPipPip
  • Advanced Member
  • 179 posts

Posted 30 September 2006 - 03:38 PM

Error with query: INSERT INTO `users` ( `UID` , `username` , `p

that's the 2nd one..
it keeps going... so i just took the beginning.

#7 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 30 September 2006 - 03:43 PM

No post the full error message. Do not cut the error message

#8 ataria

ataria
  • Members
  • PipPipPip
  • Advanced Member
  • 179 posts

Posted 30 September 2006 - 03:48 PM

Alright. I'm gonna cut my IP and pw out though..

Error with query: INSERT INTO `users` ( `UID` , `username` , `password` , `points` , `IP` , `email` , `fname` , `lname` , `gender` , `age` , `location` , `registered` , `last_login` , `admin` , `orientation` , `ethnic` , `music` , `AIM` , `YIM` , `MSN` , ) VALUES ( '', 'mike', 'password', '5000', '12.12.123', 'mike@ataria.org', 'Michael', 'Ewing', 'Male', '15', 'New York', '20', '20', '0', 'Straight', 'White', 'Alternative', 'ewingggg', '', 'xxm1kexx@hotmail.com' );
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 ') VALUES ( '', 'mike', 'password', '5000', '12.12.123', 'mike@ataria.org', 'M' at line 1

#9 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 30 September 2006 - 03:56 PM

Try this as the query:
$sql1 = "INSERT INTO `users` (`username` , `password` , `points` , `IP` , `email` , `fname` , `lname` , `gender` , `age` , `location` , `registered` , `last_login` , `admin` , `orientation` , `ethnic` , `music` , `AIM` , `YIM` , `MSN` )
VALUES ('{$username}', '{$pw}', '5000', '{$REMOTE_ADDR}', '{$email}', '{$fname}', '{$lname}', '{$gender}', '{$age}', '{$location}', '{$day}', '{$day}', '0', '{$orientation}', '{$ethnic}', '{$music}', '{$AIM}', '{$YIM}', '{$MSN}' );";

also add the following:
// help protect sql injection attacks
array_map('mysql_real_escape_string', $_POST, $_GET);

before:
extract($_POST);


#10 ataria

ataria
  • Members
  • PipPipPip
  • Advanced Member
  • 179 posts

Posted 30 September 2006 - 04:08 PM

i got...

Warning: mysql_real_escape_string() expects parameter 2 to be resource, string given in /home/ataria/public_html/preview.php on line 8

Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8

Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8

Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8

Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8

Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8

Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8

Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8

Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8

Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8

Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8

Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8

Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8

Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8

Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8

Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8

and the other error thing...

#11 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 30 September 2006 - 04:14 PM

Whoops.

The following:
array_map('mysql_real_escape_string', $_POST, $_GET);


should be:
array_map('mysql_real_escape_string', $_POST);
array_map('mysql_real_escape_string', $_GET);


#12 ataria

ataria
  • Members
  • PipPipPip
  • Advanced Member
  • 179 posts

Posted 30 September 2006 - 04:17 PM

k. that error is gone.. but...

Error with query: INSERT INTO `users` ( `UID` , `username` , `password` , `points` , `IP` , `email` , `fname` , `lname` , `gender` , `age` , `location` , `registered` , `last_login` , `admin` , `orientation` , `ethnic` , `music` , `AIM` , `YIM` , `MSN` , ) VALUES ( '', 'mike', 'password', '5000', '12.12.123', 'mike@ataria.org', 'Michael', 'Ewing', 'Male', '15', 'New York', '20', '20', '0', 'Straight', 'White', 'Alternative', 'ewingggg', '', 'xxm1kexx@hotmail.com' );
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 ') VALUES ( '', 'mike', 'password', '5000', '12.12.123', 'mike@ataria.org', 'M' at line 1

is still there...

#13 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 30 September 2006 - 04:18 PM

Thats using the old SQL query. The new on should be this:
$sql1 = "INSERT INTO `users` (`username` , `password` , `points` , `IP` , `email` , `fname` , `lname` , `gender` , `age` , `location` , `registered` , `last_login` , `admin` , `orientation` , `ethnic` , `music` , `AIM` , `YIM` , `MSN` )
VALUES ('{$username}', '{$pw}', '5000', '{$REMOTE_ADDR}', '{$email}', '{$fname}', '{$lname}', '{$gender}', '{$age}', '{$location}', '{$day}', '{$day}', '0', '{$orientation}', '{$ethnic}', '{$music}', '{$AIM}', '{$YIM}', '{$MSN}' );";


#14 ataria

ataria
  • Members
  • PipPipPip
  • Advanced Member
  • 179 posts

Posted 30 September 2006 - 04:25 PM

OMG. IT WORKED.
THANKS SO MUCH!

#15 ataria

ataria
  • Members
  • PipPipPip
  • Advanced Member
  • 179 posts

Posted 30 September 2006 - 04:29 PM

another thing .. sorry for so many things..
for the IP thing... it only shows 2 digits.
how do i make it show it all?

#16 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 30 September 2006 - 04:31 PM

not sure what you mean. Could you explain that a bit more.

amke sure the IP column in the database is set to 15 if its a varchar field. As an IP addy has a max 12 numbers and 3 periods

#17 ataria

ataria
  • Members
  • PipPipPip
  • Advanced Member
  • 179 posts

Posted 30 September 2006 - 04:35 PM

in the database (mysql), it says 'IP'
then in the row it's '24' (for one user)
and, '65' for me.


#18 ataria

ataria
  • Members
  • PipPipPip
  • Advanced Member
  • 179 posts

Posted 30 September 2006 - 04:36 PM

And, I just registered an account and, it says '65' still.
(i changed it to... int(15)

#19 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 30 September 2006 - 04:39 PM

Thats why. INT only accepts integer values (whole numbers). MySQL is thinking your're adding a float to the IP field, so it strips of the decimals. Change the field type for the IP column to VARCHAR instead.

#20 ataria

ataria
  • Members
  • PipPipPip
  • Advanced Member
  • 179 posts

Posted 30 September 2006 - 04:42 PM

Alright. Changed.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users