0

When I run this code, nothing shows up.

<?php
$host="***********"; // Host name 
$username="**********"; // Mysql username 
$password="***********"; // Mysql password 
$db_name="**********"; // Database name 
$tbl_name="members"; // Table name 

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");
$query="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result)){
echo "ID Number: ". $row['id']. "<br />Name: ". $row["name"]. "<br />Project Status: ". $row["status"]. "<br />Day Started: ". $row["start"]. "<br />Estimated Finish Date: ". $row["finish"]. "<br />Main Phone Number: <a href='tel:". $row["mainphone"]. "'>". $row["mainphone"]. "</a>". "<br />Business Phone Number: <a href='tel:". $row["businessphone"]. "'>". $row["businessphone"]. "</a>". "<br />Home Phone Number: <a href='tel:". $row["homephone"]. "'>". $row["homephone"]. "</a>". "<br />Fax: ". $row["fax"]. "<br />Email Address: ". $row["email"]. "<br />Job Estimate: $". $row["estimate"]. "<br />Job Address: ". $row["address"] ;
}
mysql_close();
?>

It comes up a plain white screen. Before I added while Everything showed up correctly except for the data it was supposed to pull from SQL. If you could point out any flaws or reasons why it wouldn't be working, I would greatly appreciate it.

tycemang
  • 11
  • 4
  • check log there is error because of that its showing white screen. enable your error show. ini_set('display_errors',1); ini_set('display_startup_errors',1); error_reporting(-1); – Prashant Srivastav Jul 27 '15 at 20:43
  • **WARNING**: If you're just learning PHP, please, do not learn the obsolete `mysql_query` interface. It's awful and is being removed in future versions of PHP. A modern replacement like [PDO is not hard to learn](http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/). A guide like [PHP The Right Way](http://www.phptherightway.com/) can help explain best practices. Always be absolutely **sure** your user parameters are [properly escaped](http://bobby-tables.com/php) or you will have severe [SQL injection bugs](http://bobby-tables.com/). – tadman Jul 27 '15 at 20:51
  • **WARNING**: Writing your own access control layer is not easy and there are many opportunities to get it severely wrong. In this short example you have a number of dangerous [SQL injection vulnerabilities](http://bobby-tables.com/) coming from a reckless lack of [proper escaping](http://bobby-tables.com/php). Please, do not write your own authentication system when any modern [development framework](http://codegeekz.com/best-php-frameworks-for-developers/) like [Laravel](http://laravel.com/) comes with a robust [authentication system](http://laravel.com/docs/security) built-in. – tadman Jul 27 '15 at 20:52

0 Answers0