Page 1 of 1

menu display function only displays on entry page

Posted: Mon Mar 10, 2003 4:15 am
by deejay
Here is the code for a function i have made to display a menu which is being written from the database.

Code: Select all

function writeMainMenu()
{
    global $result;
    $num_rows = mysql_num_rows($result);

   if ($num_rows > 0) {
      echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
      while ($row = mysql_fetch_assoc($result)) &#123;
         echo '<tr> <td height="25" >';
         echo '<a href="'.$row&#1111;'link'].'"><img src="'.$row&#1111;'image'].'" width="136" height="25" alt="'.$row&#1111;'alt'].'"  border="0" /></a>'."\n";
         echo '</td></tr>';
      &#125;
      echo '</table>';
   &#125;
&#125;
this works fine on any pages that are being accessed directly, but when I come from another page to it, then it does not display. I take it the problem must be in the $result – which is

Code: Select all

$result = mysql_query("SELECT * FROM mainMenu",$db);
wouldn’t have thought it would be this as this value will be consistent, wont it.

Thank you in advance for any help to point me in right direction

Posted: Mon Mar 10, 2003 5:45 am
by volka
maybe the function hasn't been executed at all because of a fatal error? Is there something that should happen afterwards? Have you checked wether an error or notice has been reported.

Code: Select all

<?php error_reporting(E_ALL); init_set('display_errors', TRUE); ?>
at the beginning of your script file will temporarily enable the most detailed error/warning level and and puts them in the output-stream (visible in the browser document)

Posted: Mon Mar 10, 2003 6:29 am
by deejay
when i used that line of code you gave me I got an 'function doesn't exist error' on its own line.

swapped with

Code: Select all

<?php
error_reporting (E_ALL ^ E_NOTICE);
?>
and got no errors. :?

Posted: Mon Mar 10, 2003 8:16 am
by twigletmac
Try

Code: Select all

<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
?>
init_set() should have been ini_set().

Mac

Posted: Mon Mar 10, 2003 9:36 am
by deejay
still didnt report any errors. think i might write a new function from scratch and see how i get on.