Solved

Parse error unecpected T_STRING

Posted on 2008-10-20
5
331 Views
Last Modified: 2013-12-13
I am trying to create a members login page using php in dreamweaver. However, when I try to browse the login page in Internet explorer I get the followin error mesage.

Parse error: syntax error, unexpected T_STRING in C:\Inetpub\wwwroot\strictly-invite.co.uk\strictlyinvite files\html\website\login.php on line 18

I have a attached a snippet of my code including line 18. Can somebody please help as I have been stuck for exactly a week trying to figure out the problem!!
<?php
$dbhost = "localhost";
$dbname = "user";
$dbuser = "user";
$dbpass = "pass";
 
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($user) or die(mysql_error());
 
session_start();
 
$username = $_POST[username];
$password = md5($_POST[password]);
 
$query = SELECT * FROM user where username= $'username' and password= $'password';
 
$result = mysql_query($query);
 
if (mysql_num_rows($result) != 1) {
$error = Bad Login;
    include login.html;
 
} else {
    $_SESSION[username] = $username;
    include welcome.php;
}
 
?>

Open in new window

0
Comment
Question by:rafique12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 17

Expert Comment

by:HuyBD
ID: 22756021
change the line
$query = "SELECT * FROM user where username= '$username' and password= '$password'";

Open in new window

0
 
LVL 7

Expert Comment

by:mattaob
ID: 22756046
also be *VERY* careful allowing $_POST, $_GET or anyother untiltered code directly into a mysql statement - it's asking for sql injection trouble
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 22756062
$query = SELECT * FROM user where username= $'username' and password= $'password';

needs to be:

$query = "SELECT * FROM user where username= $'username' and password= $'password'";
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 22756063
sorry, too slow...
0
 

Author Closing Comment

by:rafique12
ID: 31507754
Thankyou so much friend I had been stuck for a whole week and almost accepted defeat!
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question