Computing.Net > Forums > Web Development > PHP blank page

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

PHP blank page

Reply to Message Icon

Name: ChromeShark (by croftstorm)
Date: February 9, 2007 at 09:39:47 Pacific
OS: windows xp
CPU/Ram: 512mb
Product: Compaq
Comment:

This seems like a simple PHP MySQL problem, but it has me stumped.

The page has the following php code:

<?
$query = "SELECT * FROM test";
$result = mysql_query($query);
$totalrows = mysql_num_rows($result);
print "$totalrows";
?>

The test table has 20 rows, so the page should just display the number '20'. But it returns blank. The interesting thing is that this code knocks out anything else on the page and it all returns blank. Anyone see what I'm doing wrong?

croftstorm.net



Sponsored Link
Ads by Google

Response Number 1
Name: Laler
Date: February 9, 2007 at 10:34:08 Pacific
Reply:

about the blank, maybe the server setting sets "blank" on error. Some hosting companies're doing this. Not a place for developers.

Your query is quite simple. As long as the connection is correct [ mysql_connect() or mysql_pconnect() ], the db correctly selected [ mysql_select_db() ], and the table `test` exists, it should be working.

---
Fubar


0

Response Number 2
Name: Michael J (by mjdamato)
Date: February 9, 2007 at 12:37:32 Pacific
Reply:

A few things:

1) Eitehr you are not connecting to the database or you did not include the code in your post.

2) You should always include error handling in your database action: connecting to the database, running a query, etc. I prefer NOT to use "die" in the final production version (instead handling errors gracefully). But, there's no problem using it during development.

Based upon your code above I think the problem is definitely a problem with the query. Use this instead and report back what the error is:

<?php
$query = "SELECT * FROM test";
$result = mysql_query($query) or die (mysql_error());
$totalrows = mysql_num_rows($result);
print "$totalrows";
?>

Michael J


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: PHP blank page

Blank Page in Firefox www.computing.net/answers/webdevel/blank-page-in-firefox/1984.html

PHP scripts set-up www.computing.net/answers/webdevel/php-scripts-setup/902.html

creating a php upload page www.computing.net/answers/webdevel/creating-a-php-upload-page/2791.html