0

I am trying to build a php blog from scratch. Everything is working except the menu. I run this code on a different CMS and it is working, but on the blog I am building is not.

<div id="navigation">
<ul class="menu">
<li><a href="<?php echo DIR;?>">HOME</a></li>
<?php
    //get the rest of the pages
    $sql = mysql_query("SELECT * FROM pages WHERE isRoot='1' ORDER BY pageID");
    while ($row = mysql_fetch_object($sql))
    {
        echo "<li><a href=\"".DIR."?p=$row->pageID\">$row->pageTitle</a></li>"; 
    }
?>

I get the Home link but not the rest.

Thank you!

Gerald Schneider
  • 17,416
  • 9
  • 60
  • 78
Alin
  • 1
  • 1
    What do you mean by *not working* ? Did you get any errors ? –  Dec 30 '14 at 15:21
  • Welcome to StackOverflow! How do you "run this code"? (You can edit your question to add precisions) – Dettorer Dec 30 '14 at 15:22
  • Please post the error – Utkarsh Dixit Dec 30 '14 at 15:23
  • 2
    Add error reporting to the top of your file(s) right after your opening ` – Funk Forty Niner Dec 30 '14 at 15:26
  • 1
    Please, [don't use `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) in new code. They are no longer maintained and are [officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). Learn about [prepared statements](http://en.wikipedia.org/wiki/Prepared_statement) instead, and use [PDO](http://us1.php.net/pdo) or [MySQLi](http://us1.php.net/mysqli). – Jay Blanchard Dec 30 '14 at 15:29
  • 1
    where is your database connection?? – A l w a y s S u n n y Dec 30 '14 at 15:34

1 Answers1

-1

First, and a minor note at that, you might want to look into your usage of quotation marks in the echo line. i.e.:

<?php echo "<li><a href=\"".DIR."?p=".$row->pageID."\">".$row->pageTitle."</a></li>"; ?>

instead of:

<?php echo "<li><a href=\"".DIR."?p=$row->pageID\">$row->pageTitle</a></li>"; ?>

I bring this up because I think this is where your issue lies. If you look into the source code, it would truly clarify whether this is truly the issue.

In regards to cross-CMS support, some CMS suites have different magicquotes usage and filtering schemes, which would explain you're confusion that way. In my personal opinion, I would assume that your inclusion of PHP within the echo statement without concatenation is the root of your issue. Post the PHP error or source code of the element in question (in Chrome, right click one the menu and select "Inspect element"). This will clear up any of the questions we have and enable us to help you further if my solution isn't correct.

gen_Eric
  • 223,194
  • 41
  • 299
  • 337