menu display function only displays on entry page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
deejay
Forum Contributor
Posts: 201
Joined: Wed Jan 22, 2003 3:33 am
Location: Cornwall

menu display function only displays on entry page

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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)
User avatar
deejay
Forum Contributor
Posts: 201
Joined: Wed Jan 22, 2003 3:33 am
Location: Cornwall

Post 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. :?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Try

Code: Select all

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

Mac
User avatar
deejay
Forum Contributor
Posts: 201
Joined: Wed Jan 22, 2003 3:33 am
Location: Cornwall

Post by deejay »

still didnt report any errors. think i might write a new function from scratch and see how i get on.
Post Reply