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
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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.