php safe mode database connection
Posted: Thu Feb 19, 2009 4:34 am
I' have great difficulty getting any of my php scripts which contain a database connection to run on my php safe mode server.
Does anybody have any advice on modifications i might have to make to the code below such that it will execute properly?
I'm very desperate so help is seriously appreciated!
Thanks in advance!
Does anybody have any advice on modifications i might have to make to the code below such that it will execute properly?
Code: Select all
<?php
$mysql = mysql_connect("localhost","anmluser","******","anmldb");
if(mysql_connect_errno()){
printf("Connect failed: %s\n", mysql_connect_error());
exit();
}else{
$sql = "SELECT news_name, news_date, news_location, news_desc from tblnews order by news_id desc limit 5";
$res = mysql_query($mysql, $sql);
if($res){
while($newArray = mysql_fetch_array($res, MYSQL_ASSOC)){
$title=$newArray['news_name'];
$date=$newArray['news_date'];
$location=$newArray['news_location'];
$desc=$newArray['news_desc'];
echo "<table cellpadding='4' style='border-bottom-style: dotted; border-color:purple;'>";
echo "<tr>";
echo "<td><font color='green' size='3pt'><b>".$title."</b></font></td>";
echo "<td><b><i>Posted:</b> ".$date."</i></td>";
echo "</tr>";
echo "<tr>";
echo "<td colspan=2><b>Location:</b> ".$location."</td>";
echo "</tr>";
echo "<tr>";
echo "<td colspan=2>".$desc."</td>";
echo "</tr>";
echo "</table>";
echo "<br/>";
}
}else{
printf("Could not retrieve records: %s\n", mysql_error($mysql));
}
mysql_free_result($res);
mysql_close($mysql);
}
?>Thanks in advance!