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!
Usually that parse error refers to incorrect syntax, but im REALLY not seeing what I'm doing wrong so if you could point it out or something a hint anything!!
Parse error: syntax error, unexpected T_STRING in /blah/blah/i/n/t/blah/html/php/checklogin.php on line 23
<?php
//Database Information
$dbhost = "blah";
$dbname = "Administrator";
$dbuser = "Administrator";
$dbpass = "***********";
//Connect to database
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
session_start();
$username = $_POST[‘username’];
$password = md5($_POST[‘password’]);
//This below is the line with the problem and i don't see what i did wrong(it says 23 but I moved it down)
$query=“SELECT * FROM users WHERE username=’$username’ and password=’$password’”;
$result = mysql_query($query);
if (mysql_num_rows($result) !=1) {
$error = “Bad Login”;
include “/main_login.html”;
} else {
$_SESSION[‘username’] = “$username”;
include “test.hml
”;
}
?>
I believe my SQL is correct and i called it properly, all of my variables are correct I dunno whats wrong =/
session_start();
$username = $_POST['username'];
$password = md5($_POST['password']);
//This below is the line with the problem and i don't see what i did wrong(it says 23 but I moved it down)
$query="SELECT * FROM users WHERE username='$username' and password='$password' ";
Ok that was pretty stupid on my part, and Its fixed and the script works EXCEPT now i have another error, and one that I frequently get for some reason and when I fix this its with me not know how I did.
On line 27 the num_rows has an issue, and I've tried it several different ways but I don't know what it is, because I checked syntax, characters
Ok So i applied the suggestions, but no matter the input the same outcome occurs, I think its a problem in the PHP but I could be wrong =/
it clears everything and gets to that if statement but ignores the else and uses the if.
even though its telling it that if rows = < 1 it still redirects me to the home page, even if the login is correct =/
So heres the updated code after I went through and made a few changes so it would do things differently but now its like it just doens't care what input it gets, it just uses
I really don't know why my IDE does that, it uses characters it isn't supposed to use, like the majority of errors are caused by these crazy keyboard errors =/
But dude!! you have literally saved me sooo much trouble, i'm really a noob to PHP but I really should have noticed that >_<
but yeah, my site is completely functioning thanks to you!