Page 1 of 1

Access Denied - why?

Posted: Sat May 17, 2008 6:33 pm
by jjl
When I use this function I get the "access denied" error but if I take the same code and insert in directly into the html page from where the function was called, it works fine. The function is stored separately in a file that is loaded with required.
Can anyone throw any light on the subject. Thanks

function CreateMenu ($menuname)
{
//make the connection to the database
$connection = @mysql_connect($server, $dbusername, $dbpassword) or die(mysql_error());
$db = @mysql_select_db($db_name,$connection)or die(mysql_error());
echo "connected";
//build and issue the query and create the menu items
$sql = "SELECT * FROM $menu_table where `Menu` = '$menuname' ";

$result = @mysql_query($sql,$connection) or die(mysql_error());

while ($sql = mysql_fetch_object($result))
{
$filename = $sql -> Link;
$Text = $sql -> Title;
echo '<li>';
echo "<a href= $filename >$Text</a>";
echo '</li>';
}

}

Re: Access Denied - why?

Posted: Sat May 17, 2008 8:51 pm
by califdon
Probably either the file or directory permissions for the include file are not the same as for your script, so it can't read the include file.

Re: Access Denied - why?

Posted: Sat May 17, 2008 8:56 pm
by jjl
Thanks for the reply,
For some reason (I have yet to work out the intricacies of access for variables etc within php) the config file was not being read. It was required at the start of the html file under the php code. I included an include ( 'config.php') within the function and it all works fine now. Thanks again for your reply.
Jeremy