Jump to content

syntax error, unexpected T_STRING


OneEyedWillie

Recommended Posts

Hi, I am trying to use a tutorial to create a login/register script. I got the register working great and it writes to the db. My problem is with logging in. I get this error:

 

Parse error: syntax error, unexpected T_STRING in C:\ROOT\wamp\www\IsleWar\login.php on line 19

 

This is line 19:

 

$query = “select * from users where username=’$username’ and password=’$password’”;

 

Full login.php:

 

<?php

//Database Information

$dbhost = "localhost";
$dbname = "islewar";
$dbuser = "islewar";
$dbpass = "<censored password>";

//Connect to database

mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());

session_start();
$username = $_POST[‘username’];
$password = md5($_POST[‘password’]);

$query = “select * from users 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 “memberspage.php”;
}

?>

 

Anything anybody can do to help me would be great!

Link to comment
https://forums.phpfreaks.com/topic/237679-syntax-error-unexpected-t_string/
Share on other sites

I used Notepad++ and cPanel and got the same error. In Notepad++ and CoffeeCup I don't see an option for ascii formatting. In cPanel I can choose ascii but when I save, it formats it back to utf-8. Is it possible it is doing that because of me just copying/pasting from the tutorial? If I typed it would it stop the errors?

Well, rather than fighting this, just find the "  and ' characters and replace them with the ones on your keyboard.  Yes it is because you cut and pasted from an article that erroneously converted them to different characters.

Weird, there must be something wrong with either php or MySQL on my friends server. I was trying to use this on his server and was getting that error.. So I tried putting it on my server and it works great now.

 

I'll have to let him know. Thanks for all your help!

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.