![]() |
Trying to create a "sign up form"....help please
I am trying to create a sign up form and this is the error I keep getting:
Parse error: parse error, unexpected $ in /XXXX/XXXXX/public_html/signup/signup.php on line 37 I have been doing some searching and found that it seems to be a sytax error of some sort but I can't find the problem. Maybe a second or third set of eyes can help. Here's the source code: <?php $FirstName = $_GET["FirstName"]; $LastName = $_GET["LastName"]; $Email = $_GET["Email"]; $Phone = $_GET["Phone"]; $Address = $_GET["Address"]; $City = $_GET["City"]; $State = $_GET["State"]; $Zip = $_GET["Zip"]; $Username = $_GET["Username"]; $Password = $_GET["Password"]; $LastLogin = date("Y-m-d"); print "FirstName is $FirstName<br>\n"; print "Email is $Email<br>\n"; mysql_connect("localhost", "dbname", "dbpassword"); $result = mysql_query( "insert into dbname.dbtable (FirstName, LastName, Email, Phone, Address, City, State, Zip, Username, Password, LastLogin) values ('$FirstName', '$LastName', '$Email', '$Phone', '$Address', '$City', '$State', '$Zip', '$Username', '$Password', '$LastLogin')" ); if ($result) { echo <<<EOT Thank You Your signup is appreciated. EOT; } else { echo "Something went awry with the awful SQL"; } mysql_close(); ?> If someone could look over this and tell me what I'm doing wrong I'd appreciate it.... |
Hi,
not sure exactly. i have changed the code(just to correct something which you should think about (not necessary, bu tgood to have) try this code and see if error is again there PHP Code:
|
Parse error: parse error, unexpected T_VARIABLE
Nope didn't seem to work, different error but still not working. One note * On your comment, was I suppose to add that info that you added to each one of those inputs? |
YES, you should use that function to ALL inputs made by user, which you are going to store in database.
in new version the new function is mysql_real_escape_string() which is recommended to use, but, you have to make sure if it exists in your version or not or you can do this $var = (function_exists('mysql_real_escape_string'))?mysq l_real_escape_string($user_info):mysql_escape_stri ng($user_info); its jsut saying if that function exists then use that else use other one ABOUT THE ERROR please specify the line number where error occured |
WOW...ok I'm a serious newb when it comes to all this so if I ask many questions or repeat myself please excuse my ignorance. I'll try and digest what you just explained to me but to answer your question the error line number is the very last line number in the script. So if ?> is line 37 the error will be on line 37, that is for the original problem. The 2nd problem ( your fixed version ) Says the error is on line 24. Hope this helps
*** Just a side note I'm taking a lesson from the Apache, MySQL, & PHP WebDevelopment for Dummies book and modifying it *** So the first set of code I posted it the modified version of their "example" in the book. I can post that here if you like???? |
ooops ws a syntax, try again
also i was newbie once too. so, don't worry, maybe you'll get it in less time thatn me :) PHP Code:
|
Nothing owuld be the problem with a missing ; at the end of this code:
PHP Code:
Fixed: PHP Code:
|
Parse error: parse error, unexpected T_SL, expecting ',' or ';' in /XXXX/XXXXXXXX/public_html/signup/signup.php on line 28
LOL getting frustrated like me yet? I really really appreciate your help on this. I've been working on it for almost 8 hours now and I'm about 2 lines of code away from ripping out my eye balls...hehe NOT really but you understand what I mean. Here's the revised up to date code: <?php $FirstName = mysql_escape_string($_GET["FirstName"]);//use this function on all the input before storing it in database $LastName = mysql_escape_string($_GET["LastName"]); $Email = mysql_escape_string($_GET["Email"]); $Phone = mysql_escape_string($_GET["Phone"]); $Address = mysql_escape_string($_GET["Address"]); $City = mysql_escape_string($_GET["City"]); $State = mysql_escape_string($_GET["State"]); $Zip = mysql_escape_string($_GET["Zip"]); $Username = mysql_escape_string($_GET["Username"]); $Password = mysql_escape_string($_GET["Password"]); $LastLogin = date("Y-m-d"); print "FirstName is $FirstName<br>\n"; print "Email is $Email<br>\n"; $con = @mysql_connect("localhost", "dbuser", "dbpassword"); if($con) { $query = "insert into dbname.table (FirstName, LastName, Email, Phone, Address, City, State, Zip, Username, Password, LastLogin)". "values('$FirstName', '$LastName', '$Email', '$Phone', '$Address', '$City', '$State', '$Zip', '$Username', '$Password', '$LastLogin')"; $result = mysql_query($query); if ($result) { echo <<<EOT Thank You Your signup is appreciated. EOT; } else { echo mysql_error(); } mysql_close($con); } else { echo 'Could not connect to database<br>'; } ?> |
Quote:
|
Quote:
did you try the code i posted second time?? and also try putting this error_reporting(E_ALL); as the very first line of your script SIDE NOTE: programming is time consuming specially errors, so start living with this. and as you can see my signatures, Errors = Better programming. because next time you'll try not to do the same error and even if you do get the error, you'll know what it was. makes you a better programmer. |
Think maybe it's the signup.html form I'm using then? That is calling this signup.php script?
|
No, its the script. post the code WHICH YOU ARE USING NOW
|
Quote:
|
oh ok, sorry couldn't get the meaning
|
Quote:
|
PHP Code:
|
ok change this
PHP Code:
Quote:
EOT;(not even space) give it a try EDIT: had to use [quote] because i don't know why but [php] tags din't show it properly |
Ok we've made some progress:
It looks like I'm not filling out my dbuser, dbpass, db, and dbtable info correctly, tell me what you think. Quote:
PHP Code:
|
About database i can't say becasue you should know what is the name of the table you are using
errors it seems that the names you are using in $_GET[] are not proper and the ydon't exist. also try doing this to avoid these kinda errors $LastName = (isset($_GET["LastName"]))?mysql_escape_string($_GET["LastName"]):''; it'll check if the variable is set, if not then it'll make it equal to space EDIT: just noticed you din't use mysql_select_db('database_name') to select the dataabse you want to work on |
Code:
<html>PHP Code:
Now in the members database and the clients table there is "FirstName, LastName, Email, etc...." And I made sure to use caps where they were and no spaces so that should'nt be the problem either right? |
| All times are GMT. The time now is 08:38 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0