I am very new to using PHP and calling up data from a MySQL database, and ask for assistance from anyone that could help.
The following is my HTML code:
<html>
<head>
<title></title>
</head>
<body>
<?php
// connect to database
$host="localhost";
$user="username";
$pass="password";
$database="databasename";
$connect=mysql_connect($host,$user,$pass) or die("Could not connect.");
mysql_select_db($database); or die("Could not select database.");
// get data from table
$result=mysql_query("SELECT * FROM tablename");
?>
<?php
echo "<table border='1' color='000000' cellpadding='0' cellspacing='0'>";
echo "<tr><th>ONE</th><th>TWO</th></tr>";
while($row=mysql_fetch_array($result)) {
echo "<tr><td>";
echo $row['one'];
echo "</td><td>";
echo $row['two'];
echo "</td></tr>;
}
echo "</table>";
?>
</body>
</html>
In the database itself, from phpmyadmin, I have the following fields:
id, int(11), no null, auto_increment, primary key
one,text, no null
two, text, no null
When I run the PHP file all I get is a blank screen - no error, no nothing. I wish there was an error message instead as it would lead me to how to fix this problem.
I am sure its something simple that I missed and I'd appriciate the help. Thanks guys. 🙂