Forum Moderators: coopster
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING on Line 14
Here is the script I am trying to run. Can anyone give me some pointers as to what is causing this?
session_start();
$username=$_POST['username'];
$password=md5($_POST['password']);
$sql="select * from usertable where username='$username' and password='$password'";
$result=mysql_query($sql);
if(mysql_num_rows($result)!=1){
$error="Login Failed";
include"login.php";
}else{
$row=mysql_fetch_array($result);
$_SESSION['username']="$username";
$_SESSION['ip']=$_SERVER['REMOTE_ADDR'];
header("Location:http://members.example.com/$row['USLP']");
}
[edited by: coopster at 1:44 pm (utc) on Nov. 29, 2004]
[edit reason] generalized url per TOS [webmasterworld.com] [/edit]
the script you show seems to be cut out of a larger scriptfile.
Try to locate line 14 in that original file. There (or even before, depending on the error) must be the error.
As far as I can see there should be a blank between the "include" and the file name. Don't know, however, if your error is related to this, as I don't know, if this is your line 14.
Regards,
R.
<?php
session_start();
$username=$_POST['username'];
$password=md5($_POST['password']);
$sql="select * from usertable where username='$username' and password='$password'";
$result=mysql_query($sql);
if(mysql_num_rows($result)!=1){
$error="Login Failed";
include "login.php";
}else{
$row=mysql_fetch_array($result);
$_SESSION['username']="$username";
$_SESSION['ip']=$_SERVER['REMOTE_ADDR'];
header("Location:http://members.example.com/{$row['USLP']}");
}
?>
header("Location: [members.example.com...]
session_start();
$username=$_POST['username'];
$password=md5($_POST['password']);
$sql="select * from usertable where username='$username' and password='$password'";
print $sql;
I get the same message whether I fill out a username or not.
The username is blank every time? If so, then there's the problem. If the username is there, when you actually type it in, AND the exact password/username pair exists in the db, then I'm running out of ideas.
Try changing this line:
$result=mysql_query($sql) or die(mysql_error());
This will print any mysql errors that occur.