Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Senior Member leprechaun13's Avatar
    Join Date
    May 2005
    Location
    Northampton
    Posts
    487
    Member #
    10058
    Can somebody tell me why I am getting a
    Code:
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/fhlinux176/d/development.customcomputerservices.co.uk/user/htdocs/leancms/includes/leftcol.php on line 8
    Code:
    Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ']' in /home/fhlinux176/d/development.customcomputerservices.co.uk/user/htdocs/leancms/includes/midcol.php on line 13
    error with the following PHP
    PHP Code:
    <div class="leftcol">
    <?php
            $select 
    "SELECT name,href
                FROM leancms_menu"
    ;
            
    //build query
            
    $results mysql_query($select,$dbconnect);
            
    //execute query
            
    while ($row mysql_fetch_array($results)) {
            
    // get each element
            
    $linkname $row['name'];
            
    $linkhref $row['href'];
            
    // Print Menu
            
    echo <<<END
            <ul id="menu">
                <li><a href="
    $linkhref;">$linkname;</a></li>
            </ul>
    END;
            }
    ?>
    </div>
    Regards Phil,


  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Well, the mysql_fetch_result issue is because your query failed and you're not checking to see if that happens (add an or die(mysql_error()) and you can see the error). The second issue is a little weirder. Do heredoc strings start with 3 < or just 2?

  4. #3
    Senior Member Eddy Bones's Avatar
    Join Date
    Jan 2004
    Location
    Washington, USA
    Posts
    1,054
    Member #
    4651
    Heredoc starts with 3. Heredoc is a bit odd though because you cannot have any whitespace before the beginning or ending identifier, so the tab must be removed from the quoted code.

  5. #4
    Senior Member leprechaun13's Avatar
    Join Date
    May 2005
    Location
    Northampton
    Posts
    487
    Member #
    10058
    thanks guys got it working
    Regards Phil,


  6. #5
    Senior Member leprechaun13's Avatar
    Join Date
    May 2005
    Location
    Northampton
    Posts
    487
    Member #
    10058
    Ive got that working but ive encountereda another problem
    ive got index.php
    PHP Code:
    <?php include 'includes/config.php'?>
    <html>
    <head>
    <title>LeanCMS</title
    <link href="css/style.css" type="text/css" media="screen" rel="stylesheet" />
    <body>
    <table>
    <tr>
    <td><ul><?php include ('includes/leftcol.php'?></ul></td>
    <td><?php include ('includes/midcol.php'?></td>
    <td>Hello World</td>
    </tr>
    </table>
    </body>
    </html>
    includes/leftcol.php
    PHP Code:
    <?php
    $menuselect 
    "SELECT name,href
    FROM leancms_menu"
    ;
    //build query
    $menuresults mysql_query($menuselect,$dbconnect);
    //execute query
    while ($menurow mysql_fetch_array($menuresults)or die(mysql_error())) {
    // get each element
    $linkname $menurow['name'];
    $linkhref $menurow['href'];
    // Print Menu
    echo <<<END
    <li><a href="$linkhref">$linkname</a></li>
    END;
    }
    ?>
    and includes/midcol.php
    PHP Code:
    <?php
    $menuselect 
    "SELECT name,href
    FROM leancms_menu"
    ;
    //build query
    $menuresults mysql_query($menuselect,$dbconnect);
    //execute query
    while ($menurow mysql_fetch_array($menuresults)or die(mysql_error())) {
    // get each element
    $linkname $menurow['name'];
    $linkhref $menurow['href'];
    // Print Menu
    echo <<<END
    <ul id="menu">
    <li><a href="
    $linkhref">$linkname</a></li>
    </ul>
    END;
    }
    ?>
    but when i open index.php all it does is outputs the menu it doesnt output the content. viewable here http://development.customcomputerser...co.uk/leancms/
    Regards Phil,


  7. #6
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Quote Originally Posted by Eddy Bones
    Heredoc starts with 3. Heredoc is a bit odd though because you cannot have any whitespace before the beginning or ending identifier, so the tab must be removed from the quoted code.
    Ah, yes. Ruby is slightly different with heredoc -- starts with two, or with <<- if you want to be able to have whitespace before the end identifier :-P


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:08 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com