Reputation: 391
I am using php to access a mysql database and have Safari render the php code. I have everything setup on my Mac running Mountain Lion. phpinfo() renders perfectly. If I use textmate and run the php code within phpmate, i can access the database and get the info I need. But when I access it within Safari, it displays the php code instead of connecting to the sql server and displaying the database.
THoughts/ideas ? I have apache working and i have mysql working. Queries to mysql using command line also work. Its just Safari that does not render the php code. Thanks.
<HTML>
<HEAD>
<TITLE> Our List of Link </TITLE>
<HEAD>
<BODY>
<?php
$dbcnx = $link = mysql_connect("localhost",'root','root');
if (!$dbcnx) {
die(mysql_error());
echo( "<P>Unable to connect to the " .
"database server at this time.</P>" );
}
if (! @mysql_select_db("UrlList") ) {
echo( "<P>Unable to locate the " .
"database at this time.</P>" );
exit();
}
?>
</BLOCKQUOTE>
</BODY>
</HTML
Upvotes: 0
Views: 191
Reputation: 657
It sounds to me like you need to set up the apache directory. When you open the php file in safari, are you just double clicking the file, or going to localhost/myfile.php? It is definitely a setup of apache to process the directory/file because currently it is not, safari is reading the file directly.
Upvotes: 1