blank page error while retrieving data from postgresql database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vellaraviteja
    New Member
    • Mar 2012
    • 8

    blank page error while retrieving data from postgresql database

    Code:
    <html>
    <body>
    <?php
    include("dbconnection.php");
    $sql=pg_query("SELECT * FROM division");
    while($row = pg_fetch_array($sql));
    {
    echo $row;
    }
    ?>
    </body>
    </html>
    Last edited by Dormilich; Mar 21 '12, 06:41 AM. Reason: Please use [CODE] [/CODE] tags when posting code.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    enable error reporting/display and post the complete error message.

    btw. do you have the PostgreSQL extension installed at all?

    Comment

    • vellaraviteja
      New Member
      • Mar 2012
      • 8

      #3
      i had created a table named as division with 4 columns, i want to display the data stored in that table.i had tried the above mentioned code and i am not getting any error message only a blank page is shown.i installed WAPP stack.please help me out, as i am new to php.i am doing my project on php using postgresql as database and apache 2.2 as a server.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        then you would have to check the server's error logs. if you get a blank screen there are only 2 possibilities
        a) you don't output anything in the script
        b) you have a server side error (script or server)

        did you check the HTML source code?
        Last edited by Dormilich; Mar 21 '12, 07:20 AM.

        Comment

        • vellaraviteja
          New Member
          • Mar 2012
          • 8

          #5
          no i did not check the html source code
          Code:
          <html>
          <body>
          <?php
          include("dbconnection.php");
          $sql=pg_query("SELECT * FROM division");
          echo $sql;
          
          ?>
          </body>
          </html>
          when i checked by writing the above code its coming as error resource id4#
          Last edited by Dormilich; Mar 21 '12, 07:41 AM. Reason: Please use [CODE] [/CODE] tags when posting code.

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            when i checked by writing the above code its coming as error resource id4#
            that's not an error, that is expected when you print a PHP resource.

            Comment

            • vellaraviteja
              New Member
              • Mar 2012
              • 8

              #7
              i think nothing is wrong on server side ..i m getting correct output for all other validations but something wrong with this code i think...what should i do to display the data stored in database..plz help me out sir

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #8
                are there data in this table at all?

                Comment

                • vellaraviteja
                  New Member
                  • Mar 2012
                  • 8

                  #9
                  yes we stored some data..

                  Comment

                  • Dormilich
                    Recognized Expert Expert
                    • Aug 2008
                    • 8694

                    #10
                    then your original code should print "Array" as many times as there are rows.

                    Comment

                    • vellaraviteja
                      New Member
                      • Mar 2012
                      • 8

                      #11
                      are there any mistakes in the code i posted above..?

                      Comment

                      • Dormilich
                        Recognized Expert Expert
                        • Aug 2008
                        • 8694

                        #12
                        depends on what you consider a mistake. but pg_fetch_array( ) returns an array and if you echo an array you get "Array".

                        Comment

                        • vellaraviteja
                          New Member
                          • Mar 2012
                          • 8

                          #13
                          nothing is displayed sir..what should i do now to dispay the data..?plz help me out

                          Comment

                          • Dormilich
                            Recognized Expert Expert
                            • Aug 2008
                            • 8694

                            #14
                            nothing is displayed sir..
                            I doubt that, you already had output (post #5) so the HTML code must be there.

                            Comment

                            Working...