PDA

View Full Version : parse error


dzwestwindsor
06-22-2009, 05:49 PM
i was following davidj's tutorials on the log in script, and i got a parse error once i entered the correct username and password. the parse error is on my welcome.php, not my login.php. this is my code for welcome.php--

<?php
require_once("connections/connection.php"); //database connection

session_start();

if (! isset($_SESSION['id'])) (
header ("location: login.php");

exit;

)

$id = $_SESSION ['id'];

/////////////////////////
$query = sprintf ("SELECT * FROM users where user_id = '$id' ");
$result = @mysql_query($query);
$rowAccount = @mysql_fetch_array($result);
/////////////////////////

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
Welcome to the application <?php echo $rowAccount ['user_name']; ?>
</body>
</html>
and the error is this-- Parse error: parse error in D:\wamp\www\local root\Test\welcome.php on line 7

this is line 7--

header ("location: login.php"); can anyone find the problem? is it because of a problem in the welcome.php or the login.php?

bee80
06-23-2009, 08:17 PM
your using brackets ( ) instead of curly braces {} in which your code executes

if (! isset($_SESSION['id'])) (
header ("location: login.php");

exit;

)

try

if (! isset($_SESSION['id'])) {
header ("location: login.php");

exit;

}