Hi, the attached txt document (orignally login.php) brings up and error for a reason i cant figure out and im not sure wot the error means... Can some PLEASE help me figure this out caus otherwise ill have no hair on my head!
Sorry, i dont hav an online ver, only on my intranet, so sorry u'll have to see the error through your own server etc.i just copy/paste your code in my editor that color syntax and it's pretty obvious
your code:
<?php
start_session();
include "db.php";
$user=$_POST["username"];
$pass=$_POST["password"];
if ($pass!=="" || $user!=="") {
$pass=md5($pass);
$sql = mysql_query("SELECT * FROM users WHERE username='$user');
$login_check = mysql_num_rows($sql);
if ($login_check > 0) {
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key => $val ){ $$key = stripslashes( $val ); session_register($key); $_SESSION[$key]=$$key; echo '$key='.$key.' $val='.$val; }
if ($password!==$pass) { $error=2; } else {
if ($activated!==1) { $error=3; } else {
?>
<html>
<head><title>Logging you into AHHQ</title>
<meta http-equiv=refresh content="3; URL=<?php echo $_POST["from"]; ?>">
<link href=http://www.htmlforums.com/archive/index.php/"style.css" rel=stylesheet type=text/css></head>
<body><div align="center">
<table width="50%"><tr><td class="content" align="center">
<h1>Now logging you into AHHQ</h1>
If you are not redirected automatically by your broswer <a href=http://www.htmlforums.com/archive/index.php/"<?php echo $_POST["from"]; ?>">click here</a>.
</td></tr></table>
</body></html>
<?php
} } } } else {
$error=1;
}
} else { $error=4; }
if (isset($error)) {
header("Location:$_POST['from']?error=$error");
}
?>
your missing a " at the end of your query!just a remark,
you have
$login_check = mysql_num_rows($sql);
if ($login_check > 0) {
while($row = mysql_fetch_array($sql)){
why not just have
if ($row = mysql_fetch_array($sql)){
since i presume the username is unique... so the number of result is 1 or 0!and you don't need the !== in the if statement
if ($pass!=="" || $user!=="") {
should be
if ($pass!="" || $user!="") {
or you can do it this way
if ($login_check = mysql_num_rows($sql) ) {
while($row = mysql_fetch_array($sql)){
if they want to keep the num_rows.Thank you! I could ahve figured it out it was just that i was in a HUGE hurry this morning (NZ time) and i didnt have time for it so i bung it up here. Thanks again, and thanks for the extra advice im a n00b (@ php) and was just copy and pasting snippets (most is by hand though) from various tutorials (with their written permission) so didnt know any better.
Thnx again,
the now must be getting annoying...AHHQ_Man (ver 5 coming soon!)!!!!!!!! RESOLVED !!!!!!!
Ok, great just when things seem peachy, NOPE! Well if PHP's errors were easier 4 n00bs like me to understand you guys would b outta a job! Anyway, now i get this error:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in c:\apache\htdocs\ahhq5\login.php on line 43
Help? I got the updated ver attached.
!!!!!!! RESOLVED !!!!!!!!!
Yea, i figured it out, a stupid mistake i made!
Ill post the new ver on the next post.Hey, heres that newest ver!
I still gotta do some fine tuning, but no big stuff, else ill come right back here!
AND AGAIN thanks for your help b4...
Sorry, i dont hav an online ver, only on my intranet, so sorry u'll have to see the error through your own server etc.i just copy/paste your code in my editor that color syntax and it's pretty obvious
your code:
<?php
start_session();
include "db.php";
$user=$_POST["username"];
$pass=$_POST["password"];
if ($pass!=="" || $user!=="") {
$pass=md5($pass);
$sql = mysql_query("SELECT * FROM users WHERE username='$user');
$login_check = mysql_num_rows($sql);
if ($login_check > 0) {
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key => $val ){ $$key = stripslashes( $val ); session_register($key); $_SESSION[$key]=$$key; echo '$key='.$key.' $val='.$val; }
if ($password!==$pass) { $error=2; } else {
if ($activated!==1) { $error=3; } else {
?>
<html>
<head><title>Logging you into AHHQ</title>
<meta http-equiv=refresh content="3; URL=<?php echo $_POST["from"]; ?>">
<link href=http://www.htmlforums.com/archive/index.php/"style.css" rel=stylesheet type=text/css></head>
<body><div align="center">
<table width="50%"><tr><td class="content" align="center">
<h1>Now logging you into AHHQ</h1>
If you are not redirected automatically by your broswer <a href=http://www.htmlforums.com/archive/index.php/"<?php echo $_POST["from"]; ?>">click here</a>.
</td></tr></table>
</body></html>
<?php
} } } } else {
$error=1;
}
} else { $error=4; }
if (isset($error)) {
header("Location:$_POST['from']?error=$error");
}
?>
your missing a " at the end of your query!just a remark,
you have
$login_check = mysql_num_rows($sql);
if ($login_check > 0) {
while($row = mysql_fetch_array($sql)){
why not just have
if ($row = mysql_fetch_array($sql)){
since i presume the username is unique... so the number of result is 1 or 0!and you don't need the !== in the if statement
if ($pass!=="" || $user!=="") {
should be
if ($pass!="" || $user!="") {
or you can do it this way
if ($login_check = mysql_num_rows($sql) ) {
while($row = mysql_fetch_array($sql)){
if they want to keep the num_rows.Thank you! I could ahve figured it out it was just that i was in a HUGE hurry this morning (NZ time) and i didnt have time for it so i bung it up here. Thanks again, and thanks for the extra advice im a n00b (@ php) and was just copy and pasting snippets (most is by hand though) from various tutorials (with their written permission) so didnt know any better.
Thnx again,
the now must be getting annoying...AHHQ_Man (ver 5 coming soon!)!!!!!!!! RESOLVED !!!!!!!
Ok, great just when things seem peachy, NOPE! Well if PHP's errors were easier 4 n00bs like me to understand you guys would b outta a job! Anyway, now i get this error:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in c:\apache\htdocs\ahhq5\login.php on line 43
Help? I got the updated ver attached.
!!!!!!! RESOLVED !!!!!!!!!
Yea, i figured it out, a stupid mistake i made!
Ill post the new ver on the next post.Hey, heres that newest ver!
I still gotta do some fine tuning, but no big stuff, else ill come right back here!
AND AGAIN thanks for your help b4...