I am teaching myself php & mysql and hope I am overlooking something simple.
I am running:
ubuntu 10.10
php version 5.3.3-1ubuntu9.3
apache version Apache/2.2.16 (Ubuntu)
mysql verion 5.1.49-1ubuntu8.1
MySQL appears to be working fine and I can interact with it from a command prompt and with phpmyadmin.
A simple .php file with
<?
phpinfo();
?>
displays the php details page without problem.
After that things fall apart. I can not get even the most simple of .php data to display. for example:
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<p>
<b>An Example of PHP in Action</b><br />
<?php echo "The Current Date and Time is: <br>";
echo date("g:i A l, F j Y.");?>
</p>
<h2>PHP Information</h2>
<p>
<?php phpinfo(); ?>
</p>
</body>
</html>
The snippet above, when viewed in a browser, shows all of the html but displays the date and time php as text and doesn't display the phpinfo section at all.
The snippet below only returns a blank page. I have tried many different php files, some that attempt to connect to a database and some that don't and all give me the same problem.
<?php
$dbhost='localhost';
$dbuser='user1';
$dbpass='pass123';
$dbname='available';
$conn=mysql_connect($dbhost,$dbuser,$dbpass) or die ('You screwed something up.');
mysql_select_db($dbname);
$query = "SELECT commonName FROM available_animals";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result))
{
echo "Name :{$row['commonName']} <br>" .
}
mysql_close($conn);
?>
I have purged and reinstalled php5 but that didn't help.
Am I missing something simple here? If someone can point me in the right direction I'll be grateful.
Thanks in advance.