-1

I am writing a form that verifies a sign in according to a youtube tutorial: http://www.youtube.com/watch?v=mn0ucCuNOTI.

The thing is I can't make this particular page work:

    <?php include_once("db.php") 
     session_start();
     ?>

    <?php
$user = $_POST['name'];
$pass = $_POST['pwd'];

 $sql="SELECT count(*) from phplogin WHERE(username='$user' and password='$pass')";

$query = mysql_query($sql);

$result = mysql_fetch_array($query);

if($result[0] > 0) {
    $_SESSION['userName']=$user;
    echo "Succesful login!";

    echo "<br /> Welcome " .$_SESSION['userName']. "!";
    echo "<br /><a href='signupform.php' > SignUp </a>";
    echo "<br /><a href='signinform.php' > SignIn </a>";
    echo "<br /><a href='logout.php' > LogOut </a>";
}
else{
echo "Login failed!";
echo "<br /><a href='signupform.php' > SignUp </a>";
echo "<br /><a href='signinform.php' > SignIn </a>";

}
?>

The thing is when I removed start_session() the site worked (of course I haven't started to use the session for real). I don't know if the problem is in my code.

Now I get the following error message instead: Parse error: syntax error, unexpected 'session_start' (T_STRING) in C:\webserver\apache\htdocs\sign_in_up\signin.php on line 2

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Filip Eriksson
  • 975
  • 7
  • 30
  • 47

3 Answers3

3

You're simply missing a semicolon after your include_once statement:

<?php
   include_once("db.php"); // Added the missing semi-colon
   session_start();
?>
Paul
  • 139,544
  • 27
  • 275
  • 264
2

try this:

<?php include_once("db.php") ;//semi-colon was missing
     session_start();
     ?>
undone
  • 7,857
  • 4
  • 44
  • 69
2

You have a missing semi-colon.

<?php include_once("db.php"); 
 session_start();
 ?>

PHP cannot process the next function correctly due to this missing syntax.. Hence the error showing on the next line.

Daryl Gill
  • 5,464
  • 9
  • 36
  • 69