nimametu Posted November 2, 2007 Share Posted November 2, 2007 hi all could you please debug this code for me.there is a problem .the page dont load blank screen.php and mysql works properly i tested on other php files. CODE : <?php $host = "localhost"; $user = "root"; $pwd = "root"; $username = $_POST["username"]; $password = $_POST["password"]; $database = "members"; $qry = "SELECT DISTINCT password FROM staff WHERE firstname=".$username; $con = mysql_connect($host,$user,$pwd) or die("cant connect to mysql"); mysql_select_db($database,$con) or die("cant select database"); $result=mysql_query($qry,$con) or die("Invalid Username Or Password"); $pas=mysql_fetch_array($result); if (!$password==$pas[0]) { die("Invalid Username Or Password"); } $rq="SELECT * FROM ".$u; $row=mysql_query($rq,$con) or die("There Is No Messeges !"); echo ("<html> <body> <table border=1>"); for ($i=1;i=mysql_num_rows($row);$i++) { $sqry="SELECT DISTINCT messege FROM ".$u." WHERE id=".'$i'; $nresult=mysql_query($sqry,$con) or die("problem with num rows"); $print=mysql_fetch_array($nresult); echo ("<TD>".$print[0]."</TD>"); } echo ("</table></body></html>"); mysql_close($con); ?> Link to comment https://forums.phpfreaks.com/topic/75753-whats-wrong-with-this-code/ Share on other sites More sharing options...
~n[EO]n~ Posted November 2, 2007 Share Posted November 2, 2007 You have kept the query before the connection is made, keep it above $result. I think that is the problem and keep this error_reporting(E_ALL); in top of your PHP file, might show some errors. Link to comment https://forums.phpfreaks.com/topic/75753-whats-wrong-with-this-code/#findComment-383372 Share on other sites More sharing options...
rajivgonsalves Posted November 2, 2007 Share Posted November 2, 2007 on thing I notice is firstname= should be $qry = "SELECT DISTINCT password FROM staff WHERE firstname='$username'"; where is $u coming from ? Link to comment https://forums.phpfreaks.com/topic/75753-whats-wrong-with-this-code/#findComment-383374 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.