Jump to content

Parse error


budder

Recommended Posts

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /login.php on line 33

Is it the variable $username that making the error? If so what to do?

<?php
session_start();

$dbHost		=	"s";
$dbUser		=	"u";
$dbPass		=	"u";
$dbDatabase	=	"t";

$db = mysql_connect($dbHost,$dbUser,$dbPass) or die("Unable to connect.");
mysql_select_db($dbDatabase, $db) or die(mysql_error($db));

if (isset($_POST['username'])) {
$username = trim($_POST['username']);
}	else {
$username = "";
}
if (isset($_POST['password'])) {
$password = $_POST['password'];
}	else {
$password = "";
}
if (isset($_REQUEST['redirect'])) {
$redirect = $_REQUEST['redirect'];
}	else {
$redirect = "main.php";
}

if (isset($_POST['submit'])) {
$query = "SELECT USERNAME FROM site_user WHERE username='" . mysql_real_escape_string($username, $db) . "'
 AND password = password('" . mysql_real_escape_string($password, $db) . "')
$result = mysql_query($query, $db)
if (mysql_num_rows($result) > 0) {
	$_SESSION['username'] = $username; //Line 33 that makes the error.
	$_SESSION['logged'] = 1;
	header("Refresh: 5; URL=" . $redirect);
	echo "<p>Du vil blive sendt videre om 5 sekunder.</p>";
	echo "<p>Hvis du ikke bliver sendt videre så klik <a href='" . $redirect . "'>her</a></p>";
	die();
	}
else {
$error = "<p>Du har angivet et forkert brugernavn eller kodeord. Prøv igen.</p>";
}
}
?>
<html>
<head>
<title>Login</title>
</head>
<body>
<?php 
if (isset($error)) { echo $error; }
?>
<form action="login.php" method"post">
<table>
<tr>
<td>Username:</td>
<td><input type="text" name="username" maxlength="20" size="20" value="<?php echo $username; ?>" /> </td>
</tr><tr>
<td>Password:</td>
<td><input type="password" maxlength="20" size="20" value="<?php $password; ?>" /></td>
</tr><tr>
<td> </td>
<td>
<input type="hidden" name="redirect" value="<?php echo $redirect ?>" />
<input type="submit" name="submit" value="login" />
</tr>
</table>
</form>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/198994-parse-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.