Re: [PHP] displaying database output in a table
On Thu, 2010-05-27 at 17:59 -0400, Adam Richardson wrote: > On Thu, May 27, 2010 at 5:47 PM, David Mehler wrote: > > > Hello Everyone, > > Thanks for all your suggestions. Unfortunately, I've replaced > > require_once with include_once and require with include in all the > > documents, I'm still not having any luck. > > Thanks. > > Dave. > > > > > > On 5/27/10, Bob McConnell wrote: > > > From: Philip Thompson > > > > > >> On May 25, 2010, at 8:27 PM, David Mehler wrote: > > >> > > >>> Hello, > > >>> I'm trying to display mysql database output in a formatted table. My > > >>> problem is i'm getting a blank screen with no errors. I've got > > >>> debugging on, and have run the cli php on this file which produces no > > >>> errors either, but neither does it give me any output. > > >>> My eventual goal is to select the two nearest future events to the > > >>> current date. Having done that I want to display the name, location, > > >>> start date, start time, and a summary. Right now though I just want > > > to > > >>> put all information in the database in to a table. > > >>> > > >>> Here's the code. Pointers welcome. > > >>> Thanks. > > >>> Dave. > > >>> > > >>> > >>> require_once($_SERVER['DOCUMENT_ROOT'] . "/dbconnect.php"); > > >> > > >> I ran into a similar issue yesterday. Tracked it down and figured out > > >> the "required" file did not exist. It didn't show up in my dev > > >> environment b/c I had the file. When we pushed it to QA, the file had > > >> not been uploaded. The require_once() stops execution if the file > > > isn't > > >> found. Try changing it to include_once() and see if you can _any_ > > > output. > > > > > > We struggled with this as well. require terminates the process without > > > any indication of why it stopped. No error, no exception, not even a > > > whimper. Recording a basic "file not found" message in the error log > > > would be a major improvement. > > > > > > Bob McConnell > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > Can you show us what the current code looks like? > > Adam > What do you get if you just echo out $_SERVER['DOCUMENT_ROOT']? Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] displaying database output in a table
On Thu, May 27, 2010 at 5:47 PM, David Mehler wrote: > Hello Everyone, > Thanks for all your suggestions. Unfortunately, I've replaced > require_once with include_once and require with include in all the > documents, I'm still not having any luck. > Thanks. > Dave. > > > On 5/27/10, Bob McConnell wrote: > > From: Philip Thompson > > > >> On May 25, 2010, at 8:27 PM, David Mehler wrote: > >> > >>> Hello, > >>> I'm trying to display mysql database output in a formatted table. My > >>> problem is i'm getting a blank screen with no errors. I've got > >>> debugging on, and have run the cli php on this file which produces no > >>> errors either, but neither does it give me any output. > >>> My eventual goal is to select the two nearest future events to the > >>> current date. Having done that I want to display the name, location, > >>> start date, start time, and a summary. Right now though I just want > > to > >>> put all information in the database in to a table. > >>> > >>> Here's the code. Pointers welcome. > >>> Thanks. > >>> Dave. > >>> > >>> >>> require_once($_SERVER['DOCUMENT_ROOT'] . "/dbconnect.php"); > >> > >> I ran into a similar issue yesterday. Tracked it down and figured out > >> the "required" file did not exist. It didn't show up in my dev > >> environment b/c I had the file. When we pushed it to QA, the file had > >> not been uploaded. The require_once() stops execution if the file > > isn't > >> found. Try changing it to include_once() and see if you can _any_ > > output. > > > > We struggled with this as well. require terminates the process without > > any indication of why it stopped. No error, no exception, not even a > > whimper. Recording a basic "file not found" message in the error log > > would be a major improvement. > > > > Bob McConnell > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Can you show us what the current code looks like? Adam -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com
Re: [PHP] displaying database output in a table
Hello Everyone, Thanks for all your suggestions. Unfortunately, I've replaced require_once with include_once and require with include in all the documents, I'm still not having any luck. Thanks. Dave. On 5/27/10, Bob McConnell wrote: > From: Philip Thompson > >> On May 25, 2010, at 8:27 PM, David Mehler wrote: >> >>> Hello, >>> I'm trying to display mysql database output in a formatted table. My >>> problem is i'm getting a blank screen with no errors. I've got >>> debugging on, and have run the cli php on this file which produces no >>> errors either, but neither does it give me any output. >>> My eventual goal is to select the two nearest future events to the >>> current date. Having done that I want to display the name, location, >>> start date, start time, and a summary. Right now though I just want > to >>> put all information in the database in to a table. >>> >>> Here's the code. Pointers welcome. >>> Thanks. >>> Dave. >>> >>> >> require_once($_SERVER['DOCUMENT_ROOT'] . "/dbconnect.php"); >> >> I ran into a similar issue yesterday. Tracked it down and figured out >> the "required" file did not exist. It didn't show up in my dev >> environment b/c I had the file. When we pushed it to QA, the file had >> not been uploaded. The require_once() stops execution if the file > isn't >> found. Try changing it to include_once() and see if you can _any_ > output. > > We struggled with this as well. require terminates the process without > any indication of why it stopped. No error, no exception, not even a > whimper. Recording a basic "file not found" message in the error log > would be a major improvement. > > Bob McConnell > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] displaying database output in a table
From: Philip Thompson > On May 25, 2010, at 8:27 PM, David Mehler wrote: > >> Hello, >> I'm trying to display mysql database output in a formatted table. My >> problem is i'm getting a blank screen with no errors. I've got >> debugging on, and have run the cli php on this file which produces no >> errors either, but neither does it give me any output. >> My eventual goal is to select the two nearest future events to the >> current date. Having done that I want to display the name, location, >> start date, start time, and a summary. Right now though I just want to >> put all information in the database in to a table. >> >> Here's the code. Pointers welcome. >> Thanks. >> Dave. >> >> > require_once($_SERVER['DOCUMENT_ROOT'] . "/dbconnect.php"); > > I ran into a similar issue yesterday. Tracked it down and figured out > the "required" file did not exist. It didn't show up in my dev > environment b/c I had the file. When we pushed it to QA, the file had > not been uploaded. The require_once() stops execution if the file isn't > found. Try changing it to include_once() and see if you can _any_ output. We struggled with this as well. require terminates the process without any indication of why it stopped. No error, no exception, not even a whimper. Recording a basic "file not found" message in the error log would be a major improvement. Bob McConnell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] displaying database output in a table
On Thu, 2010-05-27 at 13:16 -0500, Philip Thompson wrote: > On May 25, 2010, at 8:27 PM, David Mehler wrote: > > > Hello, > > I'm trying to display mysql database output in a formatted table. My > > problem is i'm getting a blank screen with no errors. I've got > > debugging on, and have run the cli php on this file which produces no > > errors either, but neither does it give me any output. > > My eventual goal is to select the two nearest future events to the > > current date. Having done that I want to display the name, location, > > start date, start time, and a summary. Right now though I just want to > > put all information in the database in to a table. > > > > Here's the code. Pointers welcome. > > Thanks. > > Dave. > > > > > require_once($_SERVER['DOCUMENT_ROOT'] . "/dbconnect.php"); > > I ran into a similar issue yesterday. Tracked it down and figured out the > "required" file did not exist. It didn't show up in my dev environment b/c I > had the file. When we pushed it to QA, the file had not been uploaded. The > require_once() stops execution if the file isn't found. Try changing it to > include_once() and see if you can _any_ output. > > Hope this helps. > ~Philip > > I'd tend to try and keep scripts as self contained as possible, so I can get away with using relative paths which don't rely on variables in $_SERVER. Also, I've been led to believe that $_SERVER variables are a point of entry for injection attacks, so shouldn't be relied upon, although I'm sure that's not the case for everything in the $_SERVER array. I think this is the reason why a lot of systems and frameworks have a config file which require the paths to be set up completely, without relying on these special global arrays. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] displaying database output in a table
On May 25, 2010, at 8:27 PM, David Mehler wrote: > Hello, > I'm trying to display mysql database output in a formatted table. My > problem is i'm getting a blank screen with no errors. I've got > debugging on, and have run the cli php on this file which produces no > errors either, but neither does it give me any output. > My eventual goal is to select the two nearest future events to the > current date. Having done that I want to display the name, location, > start date, start time, and a summary. Right now though I just want to > put all information in the database in to a table. > > Here's the code. Pointers welcome. > Thanks. > Dave. > > require_once($_SERVER['DOCUMENT_ROOT'] . "/dbconnect.php"); I ran into a similar issue yesterday. Tracked it down and figured out the "required" file did not exist. It didn't show up in my dev environment b/c I had the file. When we pushed it to QA, the file had not been uploaded. The require_once() stops execution if the file isn't found. Try changing it to include_once() and see if you can _any_ output. Hope this helps. ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] displaying database output in a table
At 9:27 PM -0400 5/25/10, David Mehler wrote: I'm trying to display mysql database output in a formatted table. My problem is i'm getting a blank screen with no errors. -snip- Not that this is the problem, but "@" suppresses error reporting. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] displaying database output in a table
On Tue, May 25, 2010 at 9:27 PM, David Mehler wrote: > Hello, > I'm trying to display mysql database output in a formatted table. My > problem is i'm getting a blank screen with no errors. I've got > debugging on, and have run the cli php on this file which produces no > errors either, but neither does it give me any output. > My eventual goal is to select the two nearest future events to the > current date. Having done that I want to display the name, location, > start date, start time, and a summary. Right now though I just want to > put all information in the database in to a table. > > Here's the code. Pointers welcome. > Thanks. > Dave. > > require_once($_SERVER['DOCUMENT_ROOT'] . "/dbconnect.php"); > > function displayEvents($result) { > echo "Two Next Upcoming Events.\n"; > ?> > > > > Event Location. > Event Summary > Event Time > > > while ($row = @ mysql_fetch_row($result)) > { >echo "\n"; >foreach($row as $data) > echo "\n\t $data "; >echo "\n"; > } > ?> > > > $query = "SELECT * FROM events"; > > if (!($result = @ mysql_query ($query, $db))) > > displayEvents($result); > mysql_close($db); > > } > ?> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Is that last part correct, or did you miscopy? It appears there's no opening bracket on this if: if (!($result = @ mysql_query ($query, $db))) Which would mean that only the next statement is impacted by the if. And, the next statement, which calls your displayEvents() function, is only called if the query is unsuccessful. Adam -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com
Re: [PHP] displaying database output in a table
On Tue, 2010-05-25 at 21:27 -0400, David Mehler wrote: > Hello, > I'm trying to display mysql database output in a formatted table. My > problem is i'm getting a blank screen with no errors. I've got > debugging on, and have run the cli php on this file which produces no > errors either, but neither does it give me any output. > My eventual goal is to select the two nearest future events to the > current date. Having done that I want to display the name, location, > start date, start time, and a summary. Right now though I just want to > put all information in the database in to a table. > > Here's the code. Pointers welcome. > Thanks. > Dave. > > require_once($_SERVER['DOCUMENT_ROOT'] . "/dbconnect.php"); > > function displayEvents($result) { > echo "Two Next Upcoming Events.\n"; > ?> > > > > Event Location. > Event Summary > Event Time > > > while ($row = @ mysql_fetch_row($result)) > { > echo "\n"; > foreach($row as $data) >echo "\n\t $data "; > echo "\n"; > } > ?> > > > $query = "SELECT * FROM events"; > > if (!($result = @ mysql_query ($query, $db))) > > displayEvents($result); > mysql_close($db); > > } > ?> > How have you turned on the error reporting (I assume you meant that and not debugging, which is quite different) If you've turned it on from within PHP, then a fatal error could well result in a blank screen. Try turning the display_errors on in the .htaccess, or preferably the php.ini file. If you can't, then just take a look at the raw logs (usually kept in /var/logs) Also, I'm not sure you can use $_SERVER['DOCUMENT_ROOT'] in a cli script, as I believe the $_SERVER is only set when PHP is running in a web server. Are you sure that this is being correctly populated by your server and that it is attempting to pull in the file correctly? If the file is being pulled in correctly, is it connecting to the database? I would try to avoid jumping in and out of PHP code whilst inside a function or loop, as it can lead to hard to read code. As it's very simple html output you're after, have you considered using heredoc or nowdoc syntax for it? You won't have to break out of PHP for a few lines of output, and you can keep code nicely formatted and easy to read. Thanks, Ash http://www.ashleysheridan.co.uk