Jump to content

Archived

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

ataria

Ugh. Registration Error.

Recommended Posts

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 :

[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! ";
[/code]


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.

[code]<?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{
[/code]

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!!

Share this post


Link to post
Share on other sites
Change this:
[code=php:0]mysql_query("$sql1");

$sql1;[/code]

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

Share this post


Link to post
Share on other sites
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... :(

Share this post


Link to post
Share on other sites
Error with query: INSERT INTO `users` ( `UID` , `username` , `p

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Try this as the query:
[code=php:0]$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}' );";[/code]

also add the following:
[code=php:0]// help protect sql injection attacks
array_map('mysql_real_escape_string', $_POST, $_GET);[/code]

before:
[code=php:0]extract($_POST);[/code]

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
Whoops.

The following:
[code=php:0]array_map('mysql_real_escape_string', $_POST, $_GET);[/code]


should be:
[code=php:0]array_map('mysql_real_escape_string', $_POST);
array_map('mysql_real_escape_string', $_GET);[/code]

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
Thats using the old SQL query. The new on should be this:
[code=php:0]$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}' );";[/code]

Share this post


Link to post
Share on other sites
another thing .. sorry for so many things..
for the IP thing... it only shows 2 digits.
how do i make it show it all?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
in the database (mysql), it says 'IP'
then in the row it's '24' (for one user)
and, '65' for me.

Share this post


Link to post
Share on other sites
And, I just registered an account and, it says '65' still.
(i changed it to... int(15)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

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.