Jump to content

parse error T_Variable from using a PHP self help book, where am i going wrong?


andy_b_1502

Recommended Posts

Hi guys new to this site and need some help.

 

Im using PHP 5 in easy steps by Mike McGrath, currently creating the register and login scripts for my website.

 

Ive manged to do the register script fine, it drops new user details into the MySQL database fine, however the login script gives the following error when loggin in:

 

Parse error: syntax error, unexpected T_VARIABLE in /hermes/bosweb25a/b109/ipg.removalspacecom/removal space.com/loginscript.php on line 15

 

I copied the script word-for-word, letter-for-letter, checked and re-checked. I would like to ask you guys if you see something i dont?

 

Here is the script:

 

<?php   $username = $_POST['username'];
      $password = $_POST['password'];
      $self = $_SERVER['PHP_SELF'];
      $referer = $_SERVER['HTTP_REFERER'];
#if either form field is empty return to the log-in page
if( ( !$username ) or (!$paswword ) )
   { header( "Location:$referer" ); exit(); }
#connect to MySQL
$conn = @mysql_connect ( "removalspacecom.ipagemysql.com", "removal", "123" )
   or die("Could not connect" );
#select the specified database
$rs = @mysql_select_db( "removal1", $conn )
   or die( "Could not select database" )
#create sql query
$sql="select * from users where user_name=\"$username\"
and password = password( \"$password\" )";
#execute query
$rs = myslq_query( $sql, $conn )
   or die( "Could not execute query" );
#get number of rows that match username and password
$num = mysql_numrows( $rs );
#if there is a match the log-in is authenticated
if( $num != 0 )
{ $msg = "Welcome $username - your log-in was sucessfull!"; }
else #or return to the log-in page
{ header( "location:$referer" ); exit(); }
?>
<html> <head><title>Log-in Authenticated</title></head>
<body> <?php echo( $msg ); ?> </body> </html>

 

the error is coming from line 15, the sql query line? why would there be an error from the advisory book? please help me as im stuck on this one.

 

Thanks a lot for any help i get.

 

MOD EDIT: code tags added.

Link to comment
Share on other sites

Also, this typo would cause a problem sometime anyway so you should probably fix it at the same time since it's just a few lines after

 

$rs = myslq_query( $sql, $conn )   or die( "Could not execute query" );

 

should be

$rs = mysql_query( $sql, $conn )   or die( "Could not execute query" );

 

Link to comment
Share on other sites

Any ideas why the form fails to run the script from the submit button?

 

<html><head><title>Log-in Page</title></head>

<body>

Please enter your user details to log-in here...

 

<form action = "loginscript.php" method = "post">

  <p>Username:<br />

    <input type = "text" name = "username" />

    <br />

    <br />

Password:<br />

<input type = "text" name = "password" />

<br />

<br />

<input type = "submit" value = "Log In" />

</p>

  <p> </p>

  <p><a href="index.php">back home... </a></p>

</form>

 

 

 

</body></html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.