tags:

views:

25

answers:

2

i seem to be having an error on this coding any help would be appreciated

Parse error: parse error in C:\wamp\www\espn.com\login.php on line 19

<?php

//Database Information

$dbhost = "localhost";
$dbname = "users";
$dbuser = "root";
$dbpass = "*****";

//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”;
}

?>
A: 

You are using odd quotes: instead of the proper ".

Probably happened while copying code from a web site.

The only valid string-delimiting quotes in PHP (and most other programming languages) are ' and ".

Pekka
i fixed that and this warning came up
ben
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\espn.com\login.php on line 23
ben
that means mysql_query is returning false, probably because of a syntax error or incorrect schema object name in your query
Hammerite
+1  A: 

looks like you have a fancy quote on your query, so it's not a proper string

“ vs "

localhost