ataria Posted September 30, 2006 Share Posted September 30, 2006 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]<?phpinclude ("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.."mikeYou have sucessfully registered!"but, it never does anything...so, help!! Quote Link to comment https://forums.phpfreaks.com/topic/22592-ugh-registration-error/ Share on other sites More sharing options...
ataria Posted September 30, 2006 Author Share Posted September 30, 2006 any help!? Quote Link to comment https://forums.phpfreaks.com/topic/22592-ugh-registration-error/#findComment-101377 Share on other sites More sharing options...
bljepp69 Posted September 30, 2006 Share Posted September 30, 2006 Remove the " from around " $sql1.so...mysql_query($sql1). Quote Link to comment https://forums.phpfreaks.com/topic/22592-ugh-registration-error/#findComment-101383 Share on other sites More sharing options...
wildteen88 Posted September 30, 2006 Share Posted September 30, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/22592-ugh-registration-error/#findComment-101394 Share on other sites More sharing options...
ataria Posted September 30, 2006 Author Share Posted September 30, 2006 Parse error: syntax error, unexpected T_VARIABLE in /home/ataria/public_html/preview.php on line 25I get that when i do the first one...and, i get an error with the second one... :( Quote Link to comment https://forums.phpfreaks.com/topic/22592-ugh-registration-error/#findComment-101406 Share on other sites More sharing options...
ataria Posted September 30, 2006 Author Share Posted September 30, 2006 Error with query: INSERT INTO `users` ( `UID` , `username` , `pthat's the 2nd one..it keeps going... so i just took the beginning. Quote Link to comment https://forums.phpfreaks.com/topic/22592-ugh-registration-error/#findComment-101407 Share on other sites More sharing options...
wildteen88 Posted September 30, 2006 Share Posted September 30, 2006 No post the full error message. Do not cut the error message Quote Link to comment https://forums.phpfreaks.com/topic/22592-ugh-registration-error/#findComment-101410 Share on other sites More sharing options...
ataria Posted September 30, 2006 Author Share Posted September 30, 2006 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', '[email protected]', 'Michael', 'Ewing', 'Male', '15', 'New York', '20', '20', '0', 'Straight', 'White', 'Alternative', 'ewingggg', '', '[email protected]' );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', '[email protected]', 'M' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/22592-ugh-registration-error/#findComment-101412 Share on other sites More sharing options...
wildteen88 Posted September 30, 2006 Share Posted September 30, 2006 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 attacksarray_map('mysql_real_escape_string', $_POST, $_GET);[/code]before:[code=php:0]extract($_POST);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/22592-ugh-registration-error/#findComment-101420 Share on other sites More sharing options...
ataria Posted September 30, 2006 Author Share Posted September 30, 2006 i got...Warning: mysql_real_escape_string() expects parameter 2 to be resource, string given in /home/ataria/public_html/preview.php on line 8Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/ataria/public_html/preview.php on line 8and the other error thing... Quote Link to comment https://forums.phpfreaks.com/topic/22592-ugh-registration-error/#findComment-101426 Share on other sites More sharing options...
wildteen88 Posted September 30, 2006 Share Posted September 30, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/22592-ugh-registration-error/#findComment-101431 Share on other sites More sharing options...
ataria Posted September 30, 2006 Author Share Posted September 30, 2006 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', '[email protected]', 'Michael', 'Ewing', 'Male', '15', 'New York', '20', '20', '0', 'Straight', 'White', 'Alternative', 'ewingggg', '', '[email protected]' );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', '[email protected]', 'M' at line 1is still there... Quote Link to comment https://forums.phpfreaks.com/topic/22592-ugh-registration-error/#findComment-101433 Share on other sites More sharing options...
wildteen88 Posted September 30, 2006 Share Posted September 30, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/22592-ugh-registration-error/#findComment-101435 Share on other sites More sharing options...
ataria Posted September 30, 2006 Author Share Posted September 30, 2006 OMG. IT WORKED.THANKS SO MUCH! Quote Link to comment https://forums.phpfreaks.com/topic/22592-ugh-registration-error/#findComment-101438 Share on other sites More sharing options...
ataria Posted September 30, 2006 Author Share Posted September 30, 2006 another thing .. sorry for so many things..for the IP thing... it only shows 2 digits. how do i make it show it all? Quote Link to comment https://forums.phpfreaks.com/topic/22592-ugh-registration-error/#findComment-101440 Share on other sites More sharing options...
wildteen88 Posted September 30, 2006 Share Posted September 30, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/22592-ugh-registration-error/#findComment-101442 Share on other sites More sharing options...
ataria Posted September 30, 2006 Author Share Posted September 30, 2006 in the database (mysql), it says 'IP'then in the row it's '24' (for one user)and, '65' for me. Quote Link to comment https://forums.phpfreaks.com/topic/22592-ugh-registration-error/#findComment-101444 Share on other sites More sharing options...
ataria Posted September 30, 2006 Author Share Posted September 30, 2006 And, I just registered an account and, it says '65' still. (i changed it to... int(15) Quote Link to comment https://forums.phpfreaks.com/topic/22592-ugh-registration-error/#findComment-101445 Share on other sites More sharing options...
wildteen88 Posted September 30, 2006 Share Posted September 30, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/22592-ugh-registration-error/#findComment-101447 Share on other sites More sharing options...
ataria Posted September 30, 2006 Author Share Posted September 30, 2006 Alright. Changed. Quote Link to comment https://forums.phpfreaks.com/topic/22592-ugh-registration-error/#findComment-101450 Share on other sites More sharing options...
ataria Posted September 30, 2006 Author Share Posted September 30, 2006 Thanks so much for all your help!(it worked too) Quote Link to comment https://forums.phpfreaks.com/topic/22592-ugh-registration-error/#findComment-101451 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.