By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,336 Members | 2,315 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,336 IT Pros & Developers. It's quick & easy.

blank page error while retrieving data from postgresql database

P: 8
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <?php
  4. include("dbconnection.php");
  5. $sql=pg_query("SELECT * FROM division");
  6. while($row = pg_fetch_array($sql));
  7. {
  8. echo $row;
  9. }
  10. ?>
  11. </body>
  12. </html>
Mar 21 '12 #1
Share this Question
Share on Google+
13 Replies


Dormilich
Expert Mod 5K+
P: 8,639
enable error reporting/display and post the complete error message.

btw. do you have the PostgreSQL extension installed at all?
Mar 21 '12 #2

P: 8
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.
Mar 21 '12 #3

Dormilich
Expert Mod 5K+
P: 8,639
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?
Mar 21 '12 #4

P: 8
no i did not check the html source code
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <?php
  4. include("dbconnection.php");
  5. $sql=pg_query("SELECT * FROM division");
  6. echo $sql;
  7.  
  8. ?>
  9. </body>
  10. </html>
when i checked by writing the above code its coming as error resource id4#
Mar 21 '12 #5

Dormilich
Expert Mod 5K+
P: 8,639
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.
Mar 21 '12 #6

P: 8
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
Mar 21 '12 #7

Dormilich
Expert Mod 5K+
P: 8,639
are there data in this table at all?
Mar 21 '12 #8

P: 8
yes we stored some data..
Mar 21 '12 #9

Dormilich
Expert Mod 5K+
P: 8,639
then your original code should print "Array" as many times as there are rows.
Mar 21 '12 #10

P: 8
are there any mistakes in the code i posted above..?
Mar 21 '12 #11

Dormilich
Expert Mod 5K+
P: 8,639
depends on what you consider a mistake. but pg_fetch_array() returns an array and if you echo an array you get "Array".
Mar 21 '12 #12

P: 8
nothing is displayed sir..what should i do now to dispay the data..?plz help me out
Mar 21 '12 #13

Dormilich
Expert Mod 5K+
P: 8,639
nothing is displayed sir..
I doubt that, you already had output (post #5) so the HTML code must be there.
Mar 21 '12 #14

Post your reply

Sign in to post your reply or Sign up for a free account.