PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Here Is my Code, Im not sure what is wrong..
This is the error i get... Parse error: parse error, unexpected T_STRING in /home/login.php on line 18
This Is Line 18 Itselft
$query = “select * from users where username=’$username’ and password=’$password’”;
My Full Code Is
<?php
//Database Information
$dbhost = "my database";
$dbname = "my username";
$dbuser = "my username";
$dbpass = "Passwoooord";
//Connect to database
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
u should write $query = "select * from users where username='$username' and password='$password' ";
in case of $query = “select * from users where username=’$username’ and password=’$password’”;
<?php
//Database Information
$dbhost = "st";
$dbname = "sgas";
$dbuser = "swsag";
$dbpass = "gasg";
//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 {[color=#BF0000]
$_SESSION['username']=$username;[/color]
include "memberspage.php";
}
?>
As you can see from the highlighting in the code box in your previous post, you have one too many " on L19.
That may or may not be the reason for that error, I'm not sure.
One last thing...
You should probably not put POST data straight into mysql statement. You should put it through htmlentities or something similar to prevent bad people doing bad things.
alright nothing fixed yet still same error.!!
i dont c anything wrong wit it... http://norwalkcs.com/data/login.html
Enter anything youll see the error and this is my code its fine