PHP Error

Parse error: syntax error, unexpected T_STRING in /home3/nrclan/public

Page 1 of 1

3 Replies - 1519 Views - Last Post: 07 July 2010 - 04:22 PM Rate Topic: -----

#1 Guest_James Kent*


Reputation:

PHP Error

Posted 07 July 2010 - 01:35 PM

Hello.
Could I please ask somebody to look through my code.
I am experiencing problems when trying to access my page, login.php.
Here is the error:

Parse error: syntax error, unexpected T_STRING in /home3/nrclan/public_html/Shout/login.php on line 30

Here is my code:

<?php

if(isset($_POST['submit'])){

$host="10.16.96.70"; 
$username="nrclan"; 
$password="79566ar9c7a5c"; 
$db_name="nrclan_shoutlogin"; 
$tbl_name="members";

mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$myusername=$_POST['myusername']; 
$mypassword=$_POST['mypassword'];

$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);

$count=mysql_num_rows($result);

if($count==1){
 $row = mysql_fetch_assoc($result);
 if($row['banned']==0){
  session_register("myusername");
  session_register("mypassword"); 
  header("location:myprofile.php");
 } else {
  $banned = "You have been banned!";
 }
} else {
 $iuop="Incorrect username or password!";
}
}

?>

<html>
<head>
    <title>Shout</title>
    
    <style type="text/css">
        body {
        background-image:url('background.png');
        color:white;
        font-family:Arial;
        padding:20px;
        }
    </style>
    
    <style>
    input, textarea{
	border:#F0F0F0  1px solid;
	background-color:transparent;
	color:#FFF;
    }
    input form_button{
	color:#FFF;
	background:#000;
    }
</style>
    
</head>

<body link="white" alink="white" vlink="white">
    <font size="4.5">
    <a href="index.php" style="text-decoration:none">Home</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="contact_us.php" style="text-decoration:none">Contact Us</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="register.php" style="text-decoration:none">Register</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="login.php" style="text-decoration:none">Login</a>
    </font>
    <br><br>
    <hr>
        <p><br><p>
    <font size="4.5">
        Login
             <p><br><p>
             
             By logging in, you can share questions and <br> answers with everyone around the world!<br><p><br>
<form action="<?=$PHP_SELF?>" method="post">
<table width="30%" border="0" id="table">
  <tr>
    <td width="40%"><font size="4.5">Username: </font></td>
    <td width="70%"><input name="myusername" maxlength="20" type="text" id="myusername" /></td>
  </tr>
  <tr>
    <td><font size="4.5">Password:</font></td>
    <td><input name="mypassword" maxlength="20" type="password" id="mypassword" /></td>
  </tr>
</table>
  <br>
    <input type="submit" name="submit" value="Login">
    </font>

<p><br>

<font size="4.5">
<?

echo $banned;
echo $iuop;

?>
</font>
    
</body>

</html>



Thank you for your time.
Please help! Thank you!
Kind regards,
James Kent.

Is This A Good Question/Topic? 0

Replies To: PHP Error

#2 Skaggles  Icon User is offline

  • THE PEN IS MIGHTIER
  • member icon





Reputation: 251
  • View blog
  • Posts: 640
  • Joined: 01-March 09

Re: PHP Error

Posted 07 July 2010 - 01:52 PM

   session_register("myusername");
   session_register("mypassword");



Did you mean to user $myusername and $mypassword? Also, you can try using $_SESSION instead as session_register is deprecated.

$_SESSION["myusername"] = $myusername;
$_SESSION["mypassword"] = $mypassword;


This post has been edited by Skaggles: 07 July 2010 - 01:55 PM

Was This Post Helpful? 0
  • +
  • -

#3 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,226
  • Joined: 08-June 10

Re: PHP Error

Posted 07 July 2010 - 02:08 PM

session_start() needs to be called before $_SESSION can be used.
Was This Post Helpful? 0
  • +
  • -

#4 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 542
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: PHP Error

Posted 07 July 2010 - 04:22 PM

Additionally, make sure when you do call session_start() that it is the first thing called in your script. There can be no output at all before you call it, also, as session_start() sends headers, which will be impossible after output, as any output at all causes the headers to already have been sent to the browser. It'll give you an E_WARNING level error.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1