Jump to content

[SOLVED] unexpected T_VARIABLE


S A N T A

Recommended Posts

I am working on a blog and this is the login script but i seem to be getting the error:

Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\login.php on line 6

 

this is the code

 

<?php

require("config.php");
session_start()

$db = mysql_connect($dbhost, $dbuser);
mysql_select_db($dbdatabase, $db);

if($_POST['submit']) {
sql = "SELECT * FROM logins WHERE username = '" . $_POST['username'] . "' AND password = '" . $_POST['password'] . "';";

$result = mysql_query($sql);
$numrows = mysql_num_rows($result);

if($numrows == 1) {
$row = mysql_fetch_assoc($result);
session_register("USERNAME");
session_register("USERID");

$_SESSION['USERNAME'] = $row['username'];
$_SESSION['USERID'] = $row['id'];

header("Location: " . $config_basedir);
}
else {
	header("Location: " . $config_basedir . "/login.php?error=1");
}


?>
<div id="main">

<form action="<?php echo $SCRIPT_NAME ?>" method="post">

<table>
<tr>
<td>Username</td>
<td><input type="text" name="username"</td>
</td>
<tr>
<td>Password</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Login!"></td>
</tr>
</tr>
</table>
</form>
</div>

 

Thanks in advance

 

EDIT: Just so you know the require("config.php") and the other 2 are NOT the problem

Link to comment
https://forums.phpfreaks.com/topic/103194-solved-unexpected-t_variable/
Share on other sites

<?php

require("config.php");
session_start()

$db = mysql_connect($dbhost, $dbuser);
mysql_select_db($dbdatabase, $db);

if($_POST['submit']) {
$sql = "SELECT * FROM logins WHERE username = '" . $_POST['username'] . "' AND password = '" . $_POST['password'] . "';";

$result = mysql_query($sql);
$numrows = mysql_num_rows($result);

if($numrows == 1) {
$row = mysql_fetch_assoc($result);
session_register("USERNAME");
session_register("USERID");

$_SESSION['USERNAME'] = $row['username'];
$_SESSION['USERID'] = $row['id'];

header("Location: " . $config_basedir);
}
else {
	header("Location: " . $config_basedir . "/login.php?error=1");
}


?>
<div id="main">

<form action="<?php echo $SCRIPT_NAME ?>" method="post">

<table>
<tr>
<td>Username</td>
<td><input type="text" name="username"</td>
</td>
<tr>
<td>Password</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Login!"></td>
</tr>
</tr>
</table>
</form>
</div>

 

thats the code

 

Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\login.php on line 6

 

thats the error

 

$db = mysql_connect($dbhost, $dbuser);

 

thats line 6

Cleaned up some syntax errors.

<?php

require("config.php");
session_start();

$db = mysql_connect($dbhost, $dbuser);
mysql_select_db($dbdatabase, $db);

if($_POST['submit']) {
$sql = "SELECT * FROM logins WHERE username = '" . $_POST['username'] . "' AND password = '" . $_POST['password'] . "';";

$result = mysql_query($sql);
$numrows = mysql_num_rows($result);
}
if($numrows == 1) {
$row = mysql_fetch_assoc($result);
session_register("USERNAME");
session_register("USERID");

$_SESSION['USERNAME'] = $row['username'];
$_SESSION['USERID'] = $row['id'];

header("Location: " . $config_basedir);
}
else 
{
header("Location: " . $config_basedir . "/login.php?error=1");
}

?>
<div id="main">

<form action="<?php echo $SCRIPT_NAME ?>" method="post">

<table>
<tr>
<td>Username</td>
<td><input type="text" name="username"</td>
</td>
<tr>
<td>Password</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Login!"></td>
</tr>
</tr>
</table>
</form>
</div>

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.