Feb 16, 2010 12:33 am
JasonParse error: syntax error, unexpected T_VARIABLE in /home/henomel6/
public_html/post/checklogin.php on line 24
ok, loving php so far. but i cannot for the life of me figure out what
is causing this.
code below. i've tried for about an hour to debug this.
<?php
$host="localhost"; // Host name
$username="mySQLuser"; // Mysql username
$password="mySQLpw"; // Mysql password
$db_name="myDBname"; // Database name
$tbl_name="blog"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot
connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$user=$_POST['user'];
$pass=$_POST['pass'];
// To protect MySQL injection (more detail about MySQL injection)
$user = stripslashes($user);
$pass = stripslashes($pass);
$user = mysql_real_escape_string($user);
$pass = mysql_real_escape_string($pass);
$sql="SELECT * FROM '$tbl_name' WHERE User='$user' and Pass='$pass';"
$result=mysql_query($sql); //THIS IS LINE 24
//echo $sql;
// Mysql_num_row is counting table row
//$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1
row
/*if($count==1){
// Register $myusername, $mypassword and redirect to file
"login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}*/
?>
Feb 16, 2010 12:35 am
Jasonmoment of clarity. line 23 did not have a closing semi-colon.
:smacks self on head:
Feb 16, 2010 1:10 am
Mike MoumI think you have you double quote and semicolon transposed. You don't
need a semicolon at the end of an sql string when using mysql_query.
Mike
jason wrote:
> Parse error: syntax error, unexpected T_VARIABLE in /home/henomel6/
> public_html/post/checklogin.php on line 24
>
> ok, loving php so far. but i cannot for the life of me figure out what
> is causing this.
>
> code below. i've tried for about an hour to debug this.
>
> <?php
> $host="localhost"; // Host name
> $username="mySQLuser"; // Mysql username
> $password="mySQLpw"; // Mysql password
> $db_name="myDBname"; // Database name
> $tbl_name="blog"; // Table name
>
> // Connect to server and select databse.
> mysql_connect("$host", "$username", "$password")or die("cannot
> connect");
> mysql_select_db("$db_name")or die("cannot select DB");
>
> // username and password sent from form
> $user=$_POST['user'];
> $pass=$_POST['pass'];
>
> // To protect MySQL injection (more detail about MySQL injection)
> $user = stripslashes($user);
> $pass = stripslashes($pass);
> $user = mysql_real_escape_string($user);
> $pass = mysql_real_escape_string($pass);
>
>
> $sql="SELECT * FROM '$tbl_name' WHERE User='$user' and Pass='$pass';"
> $result=mysql_query($sql); //THIS IS LINE 24
>
> //echo $sql;
>
> // Mysql_num_row is counting table row
> //$count=mysql_num_rows($result);
> // If result matched $myusername and $mypassword, table row must be 1
> row
>
> /*if($count==1){
> // Register $myusername, $mypassword and redirect to file
> "login_success.php"
> session_register("myusername");
> session_register("mypassword");
> header("location:login_success.php");
> }
> else {
> echo "Wrong Username or Password";
> }*/
> ?>
> public_html/post/checklogin.php on line 24
>
> ok, loving php so far. but i cannot for the life of me figure out what
> is causing this.
>
> code below. i've tried for about an hour to debug this.
>
> <?php
> $host="localhost"; // Host name
> $username="mySQLuser"; // Mysql username
> $password="mySQLpw"; // Mysql password
> $db_name="myDBname"; // Database name
> $tbl_name="blog"; // Table name
>
> // Connect to server and select databse.
> mysql_connect("$host", "$username", "$password")or die("cannot
> connect");
> mysql_select_db("$db_name")or die("cannot select DB");
>
> // username and password sent from form
> $user=$_POST['user'];
> $pass=$_POST['pass'];
>
> // To protect MySQL injection (more detail about MySQL injection)
> $user = stripslashes($user);
> $pass = stripslashes($pass);
> $user = mysql_real_escape_string($user);
> $pass = mysql_real_escape_string($pass);
>
>
> $sql="SELECT * FROM '$tbl_name' WHERE User='$user' and Pass='$pass';"
> $result=mysql_query($sql); //THIS IS LINE 24
>
> //echo $sql;
>
> // Mysql_num_row is counting table row
> //$count=mysql_num_rows($result);
> // If result matched $myusername and $mypassword, table row must be 1
> row
>
> /*if($count==1){
> // Register $myusername, $mypassword and redirect to file
> "login_success.php"
> session_register("myusername");
> session_register("mypassword");
> header("location:login_success.php");
> }
> else {
> echo "Wrong Username or Password";
> }*/
> ?>
Feb 16, 2010 6:29 am
Arto Viitanen16.2.2010 3:10, Mike Moum wrote:
> I think you have you double quote and semicolon transposed. You don't
> need a semicolon at the end of an sql string when using mysql_query.
>
>
> need a semicolon at the end of an sql string when using mysql_query.
>
>
>>
>> $sql="SELECT * FROM '$tbl_name' WHERE User='$user' and Pass='$pass';"
>> $result=mysql_query($sql); //THIS IS LINE 24
>>
>> $sql="SELECT * FROM '$tbl_name' WHERE User='$user' and Pass='$pass';"
>> $result=mysql_query($sql); //THIS IS LINE 24
>>
Also I think Mysql does not like table names to have hyphens; the query
would be
SELECT * FROM 'blob' WHERE User='something' and Pass='something'
--
Arto Viitanen
Previous Thread: Zero division not caught
Next Thread: Comparing Arrays Question - I can't figure out what function to use!
Related Forum Topics
- Parse error: syntax error, unexpected T_VARIABLE
- Why do I get a parse error?
- PHP/MYSQL Parse Error
- Please help with this presumably simple parse error
- What's wrong with this array? Parse error
- Undefined index or parse error: take your pick
- Pagination driving me insane
- Making strings filesystem compliant
- Best PHP Web Application for making a Social Networking Community
- How to parse url?