Jump to content


Photo

Unexpected parse code '='


  • Please log in to reply
5 replies to this topic

#1 Schlo_50

Schlo_50
  • Members
  • PipPipPip
  • Advanced Member
  • 468 posts

Posted 21 September 2006 - 07:11 AM

Parse error: parse error, unexpected '=' in /home/www/dombar0.freehostia.com/adduser2.php on line 29

I keep getting this message after i submit my user registration form. This is my first proper go at a script so i am a n00b to it, although i just can't figure out whats wrong.

Line 29 is this:

£conn=@mysql_connect( "localhost","databaseusername","databasepassword" )

This is the main script:

<?php
$self=$_SERVER['PHP_SELF'];
$firstname=$_POST['first_name'];
$surname=$_POST['sur_name'];
$username=$_POST['user_name'];
$password=$_POST['password'];

?>

<form action="http://dombar0.freeh...m/adduser2.php" method="post">
First Name: <input type="text" name="first_name"><br>
Last Name: <input type="text" name="sur_name"><br>
Username: <input type="text" name="user_name"><br>
Password: <input type="text" name="password"><br>
<input type="Submit">
</form>

<?php
if( $firstname and $surname and $username and $password )

{           
             £conn=@mysql_connect( "localhost","databaseusername","databasepassword" )
or die( "Err:Conn" );
$rs = @mysql_select_db( "dombar0_work", $conn )
or die( "Err:Db" );
$sql="INSERT INTO users ( first_name, sur_name, user_name, password)
values ( $firstname, \"surname\", \"username\", \"password\" )";

$rs = mysql_query( $sql, $conn );
if ($rs){ echo( "Records Added:$firstname $surname $username $password" ); }
}
?>

Also, while im here can someone tell me simply what '<form action' is and what i should type after it?

Thanks for any help with either questions guys ;)

Schlo_50

#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 21 September 2006 - 08:32 AM

Try changing the £ at the beginning of the line for a $ ;)

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 Schlo_50

Schlo_50
  • Members
  • PipPipPip
  • Advanced Member
  • 468 posts

Posted 21 September 2006 - 09:18 AM

Thankyou, i checked everything else apart from the '$' signs. lol Now i just need to figure out why the script loaded with no errors but didn't actually add anything to my database..:(

#4 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 21 September 2006 - 09:25 AM

Do you know what the @ in front of the function calls is doing?

@ supresses the error messages.  So if you're having issues with nothing getting into your database then I suggest you remove the @ and try again.

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#5 Schlo_50

Schlo_50
  • Members
  • PipPipPip
  • Advanced Member
  • 468 posts

Posted 21 September 2006 - 03:36 PM

Is my <form action...bit ok? Im not sure what i should put there, although the URL back to the page with the form on it seems to work..

#6 Schlo_50

Schlo_50
  • Members
  • PipPipPip
  • Advanced Member
  • 468 posts

Posted 21 September 2006 - 04:14 PM

Cheers Huggie, all is working and adding to the database now. I had some spaces where there wern't meant to be so i fixed them and added the password encryption function Mysql uses. Will probably be back soon! lol




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users