SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 28
  1. #1
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    No output from PHP - Blank Page

    please i am having a mozila firefox for this page



    Code PHP:
    <?php require_once("include/connection.php"); ?>
    <?php require_once("include/functions.php"); ?>
    <?php include("include/header.php"); ?>
    <div id="navigation">
    <ul>
        <?php
    	//3. perform database querry
    	$subject_set = mysql_query("SELECT * FROM subjects", $connection);
    	if (!$subject_set) {
    		die("Database query failed: " . mysql_error());
    		}
    		//4 use returned data
    	while($subject = mysql_fetch_array($subject_set)) {
    		echo "<li>{$subject["menu_name"]}</li>";
    		$page_set = mysql_query("SELECT * FROM pages WHERE subject_id =
    		{$subject["id"]}", $connection);
    	if (!$page_set) {
    		die("Database query failed: " . mysql_error());
    		}
    		//4 use returned data
    	while($page = mysql_fetch_array($page_set)) {
    		echo "<li>{$page["menu_name"]}</li>";
    		}
    		?>	
    </ul>
    </div> <!--end of navigation div -->
    <div id="bodycontent">
    <h3> content area</h3>
    <p> i hope this works. </p>
    </div>
    <?php
    require("include/footer.php"); ?>

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,509
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by lostty84 View Post
    please i am having a mozila firefox for this page

    What does that mean?

  3. #3
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by lostty84 View Post
    please i am having a mozila firefox for this page
    What do you mean? You're having a problem in Firefox for that page?
    What problem are you having?

  4. #4
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    the page is not loading, and there is not n the page source

  5. #5
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Pop these 2 additional lines at the top of that page, it should help.
    PHP Code:
    <?php error_reporting(-1); ?>
    <?php ini_set
    ('display_errors'true); ?>
    <?php 
    require_once("include/connection.php"); ?>
    <?php 
    require_once("include/functions.php"); ?>
    <?php 
    include("include/header.php"); ?>
    ...
    ...
    ...
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  6. #6
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    Once you've done what Anthony suggests, it will show some errors about the following:

    PHP Code:
    mysql_query("SELECT * FROM pages WHERE subject_id = {$subject["id"]}
    Here you're using double-quotation marks within double quotation marks, which doesn't work. Try changing it to :

    PHP Code:
    mysql_query("SELECT * FROM pages WHERE subject_id = {$subject['id']}
    There's a couple of those errors in there.

  7. #7
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    i have changed it but no difference , i changed "id" to 'id'
    and "menu_name" to 'menu_name'

  8. #8
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Immerse View Post
    Once you've done what Anthony suggests, it will show some errors about the following:

    PHP Code:
    mysql_query("SELECT * FROM pages WHERE subject_id = {$subject["id"]}
    Here you're using double-quotation marks within double quotation marks, which doesn't work. Try changing it to :

    PHP Code:
    mysql_query("SELECT * FROM pages WHERE subject_id = {$subject['id']}
    There's a couple of those errors in there.
    As the variable (or array) is in a double quoted string, you can omit quoting the array key altogether; I actually think it will error if you try to quote it.

    PHP Code:
    <?php
    error_reporting
    (-1);
    ini_set('display_errors'true);

    $array = array('name' => 'anthony');

    //Okay
    echo "Hello, $array[name].";

    //Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING'
    echo "Hello, $array['name'].";

    //Okay
    echo "Hello, {$array['name']}.";
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  9. #9
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    thanks, i have turned it on, but its not displaying errors, and i have also change the double quote to a single quote.
    Code PHP:
    <?php error_reporting(-1); ?>
    <?php ini_set('display_errors', true); ?>
    <?php require_once("include/connection.php"); ?>
    <?php require_once("include/functions.php"); ?>
    <?php include("include/header.php"); ?>
    <div id="navigation">
    <ul>
        <?php
    	//3. perform database querry
    	$subject_set = mysql_query("SELECT * FROM subjects", $connection);
    	if (!$subject_set) {
    		die("Database query failed: " . mysql_error());
    		}
    		//4 use returned data
    	while($subject = mysql_fetch_array($subject_set)) {
    		echo "<li>{$subject['menu_name']}</li>";
    		$page_set = mysql_query("SELECT * FROM pages WHERE subject_id =
    		{$subject['id']}", $connection);
    	if (!$page_set) {
    		die("Database query failed: " . mysql_error());
    		}
    		//4 use returned data
    	while($page = mysql_fetch_array($page_set)) {
    		echo "<li>{$page['menu_name']}</li>";
    		}
    		?>	
    </ul>
    </div> <!--end of navigation div -->
    <div id="bodycontent">
    <h3> content area</h3>
    <p> i hope this works. </p>
    </div>
    <?php
    require("include/footer.php"); ?>

    thanks for the patience

  10. #10
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,509
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    So you get a blank page in Firefox? What do you see when you right click on the blank page and choose 'View page source'?

    Does it work in other browsers?

  11. #11
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    it is blank, nothing for also for safari

  12. #12
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,509
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    1) So it's not just FF, it doesn't work in any browser.
    2) Even when you look at the HTML code, there is nothing.
    3) None of the errors Immerse found caused an error message.

    My guess is the script is stopped before it even reaches the <div id="navigation"> line.

    What is inside those includes?

  13. #13
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    the include file has the header, footer, databse connection
    Code PHP:
    <?php
    require("constant.php");
    	//1.create database connection
    	$connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS);
    	if (!$connection) {
    		die("Database connection failed: " . mysql_error());
    		}
    		//2 select database to use
    	$db_select = mysql_select_db(DB_NAME,$connection);
    	if (!$db_select) {
    		die("Database selection failed: " . mysql_error());
    		}
    		?>
    Code PHP:
    <?php
    require("constant.php");
    	//1.create database connection
    	$connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS);
    	if (!$connection) {
    		die("Database connection failed: " . mysql_error());
    		}
    		//2 select database to use
    	$db_select = mysql_select_db(DB_NAME,$connection);
    	if (!$db_select) {
    		die("Database selection failed: " . mysql_error());
    		}
    		?>
    Code PHP:
    <div id="footer">
    <ul id="footlink">
         <li><a href="contact.html">Contact us</a></li>
         <li><a href="termsandcondition.html">Terms&amp;Condition</a></li>
         <li><a href="right.html">Copyright</a></li>
         <li><a href="faq.html">Faq</a>
    </li>
    </ul>
    </div>
    </body>
    </html>
    <?php
    	//5. close connection
    	if (isset($connection)) {
    	mysql_close($connection);
    	}
    	?>

  14. #14
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by AnthonySterling View Post
    As the variable (or array) is in a double quoted string, you can omit quoting the array key altogether; I actually think it will error if you try to quote it.
    You're right! I kinda forgot because I never ever use this method of string substitution. I prefer the ages-old plain method of sticking bits together with dots.

    Back on topic:

    Can you change:

    PHP Code:
    mysql_query("SELECT * FROM pages WHERE subject_id =
            
    {$subject['id']}"$connection); 
    to:

    PHP Code:
    mysql_query("SELECT * FROM pages WHERE subject_id =
            
    {$subject[id]}"$connection); 

  15. #15
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Off Topic:

    Quote Originally Posted by Immerse View Post
    I prefer the ages-old plain method of sticking bits together with dots.
    What we need here is a ConcatentationRecursiveIteratorIterator
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  16. #16
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    i have changed it, it still not showing anything

  17. #17
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,509
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by lostty84 View Post
    the include file has the header, footer, databse connection
    You posted the database connection include twice
    It looks ok though.

    Please repost the header include.
    And the functions include?

  18. #18
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Code PHP:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <title>Reacheasy - Foremost website for easy reach of things globally</title>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <link href="easy.css" rel="stylesheet" type="text/css"/>  
    </head>
      <body>
    <div id="outer">
    <div id="page">
    <div id="header">
    <h1>Reacheasy</h1>
      <ul id="nav">
        <li class="current"><a href="index.html">Home</a></li>
         <li><a href="women.html">Women</a></li>
         <li><a href="men.html">Men</a></li>
         <li><a href="children.html">Children</a></li>
         <li><a href="homeandappliances.html">Home&amp;Appliances</a></li>
         <li><a href="visionandsound.html">Vision&amp;Sounds</a></li>
          <li><a href="motoring.html">Motoring</a></li>
          <li><a href="homemore.html">More</a></li>
          <li><a href="homecontact.html">Contact us</a></li>
          <li><a href=" rl.html">Register/Log in</a></li>
      </ul>
    </div> <!--end of navigation div -->
    </div>

  19. #19
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    Off Topic:


    Hmm, so, you feed it an array of strings, and it sticks 'em together, recursively, iteratorly. No implode?


    Quote Originally Posted by AnthonySterling View Post
    Off Topic:

    What we need here is a ConcatentationRecursiveIteratorIterator

  20. #20
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,509
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Are you sure you're calling that script?

    Try adding this line at the beginning:
    Code:
    TEST
    <?php error_reporting(-1); ?>
    <?php ini_set('display_errors', true); ?>
    <?php require_once("include/connection.php"); ?>
    <?php require_once("include/functions.php"); ?>
    <?php include("include/header.php"); ?>
    <div id="navigation">
    <ul>
        <?php
        //3. perform database querry
        $subject_set = mysql_query("SELECT * FROM subjects", $connection);
        if (!$subject_set) {
            die("Database query failed: " . mysql_error());
            }
            //4 use returned data
        while($subject = mysql_fetch_array($subject_set)) {
            echo "<li>{$subject['menu_name']}</li>";
            $page_set = mysql_query("SELECT * FROM pages WHERE subject_id =
            {$subject['id']}", $connection);
        if (!$page_set) {
            die("Database query failed: " . mysql_error());
            }
            //4 use returned data
        while($page = mysql_fetch_array($page_set)) {
            echo "<li>{$page['menu_name']}</li>";
            }
            ?>  
    </ul>
    </div> <!--end of navigation div -->
    <div id="bodycontent">
    <h3> content area</h3>
    <p> i hope this works. </p>
    </div>
    <?php
    require("include/footer.php"); ?>
    I hope TEST will show up...

  21. #21
    @php.net Salathe's Avatar
    Join Date
    Dec 2004
    Location
    Edinburgh
    Posts
    1,397
    Mentioned
    65 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Immerse View Post
    Once you've done what Anthony suggests, it will show some errors about the following:

    PHP Code:
    mysql_query("SELECT * FROM pages WHERE subject_id = {$subject["id"]}
    Here you're using double-quotation marks within double quotation marks, which doesn't work
    Off Topic:



    Random fact of the day: double-quotes within the curly-brace variable parsing within double-quotes, are fine.

    The following happily outputs the correct message.

    PHP Code:
    $example = array("msg" => "hello");
    echo 
    "{$example["msg"]}"// hello 
    You can even embed curly-brace values within curly-brace values and go really crazy using expressions which call functions all from inside the string.

    PHP Code:
    $messages = array("friendly" => "Hello""surly" => "Go away");
    $message  "friendly";
    $cereal   "kellogs";
    echo 
    "{$messages[${strtr("{$cereal}""loks""same")}]} world!"// Hello world! 
    Salathe
    Software Developer and PHP Manual Author.

  22. #22
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    thanks so far, i had followed the step of the mark up again it works on to this point
    Code PHP:
    //3. perform database querry
    		$subject_set = mysql_query("SELECT * FROM subjects", $connection);
    	if (!$subject_set) {
    		die("Database query failed: " . mysql_error());
    		}
    		//4 use returned data
    	while($subject = mysql_fetch_array($subject_set)) {
    		echo "<li>{$subject["menu_name"]}</li>";
    ]

    but when i continue to this
    it does not work, please help check i have tried all i can, am new to php


    Code PHP:
     
    //3. perform database querry
    		$subject_set = mysql_query("SELECT * FROM subjects", $connection);
    	if (!$subject_set) {
    		die("Database query failed: " . mysql_error());
    		}
    		//4 use returned data
    	while($subject = mysql_fetch_array($subject_set)) {
    		echo "<li>{$subject["menu_name"]}</li>";
    	$page_set = mysql_query("SELECT * FROM pages WHERE subject_id =
    	{$subject["id"]}", $connection);
    	if (!$page_set) {
    		die("Database query failed: " . mysql_error());
    		}
    		//4 use returned data
    	while($page = mysql_fetch_array($page_set)) {
    		echo "<li>{$page["menu_name"]}</li>";
    		}

  23. #23
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    mark up language

    please i am having problems with the mark up languge, everythin was alright but when i added this piece , it did not show anything, i also viewed the page source nothing was showing
    (this mark up is part of the full one underneath)
    Code PHP:
    $page_set = mysql_query("SELECT * FROM subjects, pages WHERE subjects.id = pages.subject_id", $connection);
    	if (!$page_set) {
    		die("Database query failed: " . mysql_error());
    		}
    		//4 use returned data
    	while($page = mysql_fetch_array($page_set)) {
    		echo "<li>{$page["menu_name"]}</li>";


    Code PHP:
    <?php require_once("include/connection.php"); ?>
    <?php require_once("include/functions.php"); ?>
    <?php include("include/header.php"); ?>
    <div id="navigation">
    <ul>
           <?php
    	//3. perform database querry
    		$subject_set = mysql_query("SELECT * FROM subjects", $connection);
    	if (!$subject_set) {
    		die("Database query failed: " . mysql_error());
    		}
    		//4 use returned data
    	while($subject = mysql_fetch_array($subject_set)) {
    		echo "<li>{$subject["menu_name"]}</li>";
    	$page_set = mysql_query("SELECT * FROM subjects, pages WHERE subjects.id = pages.subject_id", $connection);
    	if (!$page_set) {
    		die("Database query failed: " . mysql_error());
    		}
    		//4 use returned data
    	while($page = mysql_fetch_array($page_set)) {
    		echo "<li>{$page["menu_name"]}</li>";
    		}
     
    		?>
    	</ul>
    </div> <!--end of navigation div -->
    <div id="bodycontent">
     <h2> Content Area</h2>
    </div>
    </div>
    <?php require("include/footer.php"); ?>

  24. #24
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    threads merged
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  25. #25
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,053
    Mentioned
    66 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Immerse View Post

    PHP Code:
    mysql_query("SELECT * FROM pages WHERE subject_id =
            
    {$subject[id]}"$connection); 
    Do not get anyone into the habit of using unquoted string elements anywhere. In that syntax it's ok, but in code it is not.

    Code php:
    $myArray = array(
      'id' => 'hello'
      'world' => 'world'
    );
     
    echo $myArray[id]; // 'hello'
     
    define('id', 'world');
     
    echo $myArray['id']; // still 'hello'
    echo $myArray[id]; // now world, as id is a defined constant now.

    BEWARE of this. When PHP encountered an undefined constant it echoes it out - this behavior goes back all the way to before PHP 3. While this allows you to skip quote marks around array elements it is a very bad practice

    It's much better to be consistent in markup and always single quote array elements.


    EDIT: OP, check your php.ini file for any prepended scripts. An error in one of them could be the cause. Also, move the error report switch to the .htaccess file. I think the code for this is as follows:

    Code:
    php_flag_error_reporting -1
    php_flag_display_errors on
    Someone correct me if I'm wrong - which is possible since it's from memory.


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
  •