PDA

View Full Version : php : oh so confused



dinkumrocks
October 5th, 2005, 09:08 PM
Ok. Im just learning php, so bear with me.

I'm getting this error...

Parse error: parse error, unexpected T_VARIABLE in c:\Inetpub\wwwroot\adcore\login.php on line 11

withthis code..

if (isset($_POST["log_in"])) {
require_once("../adcore.php")
$check = mysql_query("select id, username, password from members where username=".$_POST["username"].";", $conn) or die(mysql_error();
if($_POST["password"] == mysql_result($check,0,"password"){
$_SESSION["uid"] = 1;//mysql_result($check,0,"id");
$_SESSION["username"] = "Paul";//mysql_result($check,0,"username");
$_SESSION["credits"] = 0;
header("Location: earn.php");
}else{
header("Location: login.php?var=invalid");
}
}


Line 11 being..$check = mysql_query("select id, username, password from members where username=".$_POST["username"].";", $conn) or die(mysql_error();


im so confused :(
-Naaman

bigmtnskier
October 5th, 2005, 09:20 PM
I'm glad to help, there were just a couple ")" and ";" issues.

I fixed up the code and this should work.


if (isset($_POST["log_in"])) {
require_once("../adcore.php");
$check = mysql_query("select id, username, password from members where username=".$_POST["username"].";", $conn) or die(mysql_error());
if($_POST["password"] == mysql_result($check,0,"password")){
$_SESSION["uid"] = 1;//mysql_result($check,0,"id");
$_SESSION["username"] = "Paul";//mysql_result($check,0,"username");
$_SESSION["credits"] = 0;
header("Location: earn.php");
}else{
header("Location: login.php?var=invalid");
}
}

or die(mysql_error(); needs the corresponding closing parenthesis like this:
or die(mysql_error());

require_once("../adcore.php") needed a semicolon

if($_POST["password"] == mysql_result($check,0,"password") needed the corresponding parenthesis like this:
if($_POST["password"] == mysql_result($check,0,"password"))

Jeff Wheeler
October 5th, 2005, 09:35 PM
Also, note that you don't need a semicolon at the end of your sql query.

dinkumrocks
October 5th, 2005, 09:50 PM
Thank you guys so much. I'm really lazy with () and whatnot.

Thanks!

bigmtnskier
October 5th, 2005, 09:52 PM
You're welcome :)