Results 1 to 2 of 2

Thread: Help With Defining Null/Not Null

  1. #1
    Join Date
    Feb 2009
    Posts
    303
    Thanks
    18
    Thanked 36 Times in 36 Posts

    Default Help With Defining Null/Not Null

    I'm making a script, that checks a MySQL database for content for a page (depending on what the value of the GET is.), and I'm having a bit of trouble with it....
    Here's my PHP:
    PHP Code:
        $getpage $_GET['page'];
        
    $sqlz mysql_query("SELECT * FROM pages WHERE `slug` = '$getpage'");
        
    $sql mysql_query("SELECT * FROM pages WHERE `slug` = '$getpage'");
        if(
    $sqlz != null){
            global 
    $sqlz;
            global 
    $sql;
            function 
    the_title() {
                global 
    $sqlz;
                while(
    $row mysql_fetch_array($sqlz)){
                    echo 
    $row[0];
                }
            }
            function 
    the_content() {
                global 
    $sql;
                while(
    $rowz mysql_fetch_array($sql)){
                    echo 
    $rowz[1];
                }
            }
        }
        else {
            function 
    the_content(){
                echo 
    '<p>The page you have requested could not be found!</p><p>Make sure that...</p><ul><li><strong>If you typed the URL yourself</strong>, all words are spelled correctly, and the page actually exists</li><li><strong>If you clicked on a link from a <em>different site</em></strong>, the link may be outdated. Please contact the owner of the site and inform them</li><li><strong>If you clicked on a link in <em>this site</em></strong>, please <a href="?page=contact">tell us</a> about it.</li></ul>';
            }
            function 
    the_title(){
                echo 
    '404 - Page Not Found';
            }
        } 
    And here's the HTML:
    Code:
    <h1><?php the_title(); ?></h1>
    <?php the_content(); ?>
    
    <div class="clear"></div>
    I can get it to display the page, but if the page isn't found, it just shows whitespace, and not what I've defined in the ELSE...

    Any help or suggestions would be greatly appreciated!

    // X96 \\
    Alex Blackie, X96 Design
    My Website
    I specialize in: HTML5, CSS3, PHP, Ruby on Rails, MySQL, MongoDB, Linux Server Administration

  2. #2
    Join Date
    Feb 2009
    Posts
    303
    Thanks
    18
    Thanked 36 Times in 36 Posts

    Default

    Never Mind... I figured it out myself. Here's my code now:
    PHP Code:
    $getpage $_GET['page'];
    $sqlz mysql_query("SELECT * FROM pages WHERE `slug` = '$getpage'");
    $sqlzy mysql_query("SELECT * FROM pages WHERE `slug` = '$getpage'");
    $sql mysql_query("SELECT * FROM pages WHERE `slug` = '$getpage'");
    if(
    mysql_num_rows($sqlz) == 0){
        function 
    the_content(){
            echo 
    '<p>The page you have requested could not be found!</p><p>Make sure that...</p><ul><li><strong>If you typed the URL yourself</strong>, all words are spelled correctly, and the page actually exists</li><li><strong>If you clicked on a link from a <em>different site</em></strong>, the link may be outdated. Please contact the owner of the site and inform them</li><li><strong>If you clicked on a link in <em>this site</em></strong>, please <a href="?page=contact">tell us</a> about it.</li></ul>';
        }
        function 
    the_title(){
            echo 
    '404 - Page Not Found';
        }
    }
    else{
        global 
    $sqlz;
        global 
    $sql;
        function 
    the_title() {
            global 
    $sqlz;
            while(
    $row mysql_fetch_array($sqlz)){
                echo 
    $row[0];
            }
        }
        function 
    the_content() {
            global 
    $sql;
            while(
    $rowz mysql_fetch_array($sql)){
                echo 
    $rowz[1];
            }
        }
        function 
    thetitle() {
            global 
    $sqlzy;
            while(
    $rowy mysql_fetch_array($sqlzy)){
                echo 
    $rowy[0];
            }
        }
    }
    function 
    sitename(){
        
    $sql3 mysql_query("SELECT * FROM system LIMIT 1");
        while(
    $row3 mysql_fetch_array($sql3)){
            echo 
    $row3[0];
        }

    Alex Blackie, X96 Design
    My Website
    I specialize in: HTML5, CSS3, PHP, Ruby on Rails, MySQL, MongoDB, Linux Server Administration

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •