RE: New to list...needing help
Bruce Whealton, Jr. wrote: Hi all, I've been frustrated with my initial efforts to run perl scripts on my server, or rather the server I use. I have tried a few simple form mailers, each of them failing with internal 500 error. 1. Post these issues to [EMAIL PROTECTED] 2. Whenever you get the 500 repsonse code, go look at the server's error log file for additional error messages. There can be any number of problems that cause the 500 error. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to display multiple web pages depending on
If this is a problem, you can use always $show = 50; ... for example. This way you will let the visitors choose only the number of records that should be skipped. But I don't think that this is a problem because either way you do your page, the visitor can create a program using the LWP library and get your pages one by one, then combine them, parse them and steal all the data from them. Teddy, Teddy's Center: http://teddy.fcc.ro/ Email: [EMAIL PROTECTED] - Original Message - From: Wiggins d'Anconia [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 29, 2003 6:12 AM Subject: Re: How to display multiple web pages depending on Octavian Rasnita wrote: It is not very hard. You can use an sql statement like this: my $sth = $dbh-prepare(select id, name, age, bla from table order by name limit ?, ?); $sth-execute($skip, $show); You can get the number of rows you want to skip ($skip) and the number of rows you want to show ($show) using the CGI package like: USE CGI; my $q = new CGI; my $skip = $q-param('skip'); my $show = $q-param('show'); You can check first the total number of rows that could be displayed, then you can compare, and if the total number of rows is bigger than the $skip + $show, meaning the latest record printed in the current page, then you can print a Next link, and ... do the same with the previous link This works well depending on the case. If the fact that you have a lot of data is valuable in itself, or if your server is subject to heavy loads, DOS attacks, etc. then you may not want to provide the method to determine the number to select as an argument as anyone could choose an arbitrarily high number to get all of the data then just use a parser to steal your data, or if you have lots of data to overload your db with multiple selects of all of the data, etc. Just something to keep in mind otherwise I like this approach and use something very similar, http://danconia.org - Original Message - From: Dennis Stout [EMAIL PROTECTED] To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, July 28, 2003 5:39 PM Subject: Re: How to display multiple web pages depending on I want to write a subroutine to select the contain of MySQL database and display the result on the browser. But I'm not sure how to get it create multiple pages if the list exceeds a given number; say 50, and create a link to the next page: like Next or 1 2 3. I think it should be easy - but I've never seen codes like that before. The idea is you create a ranged loop. for (x..x+y) { #blah } #blah is where you put all your code for retrieving lines from the SQL dbase and HTMLize them and return them. x is obtained through CGI params my $q = new CGI; my $start = $q-param('start'); x+y is obtained however 1- my $end = $start + $q-param('amount_per_page'); 2- my $end = $start + 50; whichever. Then; for ($start..$end) { #grab from db, htmllize, append to scalar variable... } print EOF; center table $scalar_from_for_loop /table /center EOF and, yeah... Should put you on the right track. I wrote my own customized interface to SQL (actually its an interface to the normal DBI interface, heh..) so I didn't write that portion since what I use would not at all be like what you would use. Dennis -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How does CGI.pm handles Content-type: text/html\n\n ?
I have read throught the CGI::Carp::fatalsToBrowser... not quite understand all, but I wonder how does this script handles the Content-type: text/html\n\n.. So in the some case s(such as warnings) this header line won't re-print ? TIA
I want to confirm the figure of a form data .
While I hit the submit the Submit button on a form ( in a normal way ), my cgi script is of cause going to read the data. My question is that does the data I read are all in the same context format ? Actually my target point is about the CRLF stuff... Is that what I read are the same even I am using 2 different web server / OS ? ( Apache, Sambar on Win32, Apache on *nix ) and does what I read are all the same whatever the browser I submitting the form? ( Netscape, IE on Win32, Netscape on *nix ) TIA
Re: How does CGI.pm handles Content-type: text/html\n\n ?
So.. if I create my own style of fatalsToBrowser. Is that possible to do in this way : Make PrintContentT.pm, which is just a simple sub to print the Content-type:blah but pushing a contenttype =1 to %ENV. At all the other CGI scripts, use PrintContentT.pm to print the header, instead, and PrintContentT, it check if exists of contentype. If exists, won't priint the header again, else, print the header. Is that Okay logically ? TIA - Original Message - From: Wiggins d'Anconia [EMAIL PROTECTED] To: LI NGOK LAM [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Wednesday, July 30, 2003 8:20 AM Subject: Re: How does CGI.pm handles Content-type: text/html\n\n ? LI NGOK LAM wrote: I have read throught the CGI::Carp::fatalsToBrowser... not quite understand all, but I wonder how does this script handles the Content-type: text/html\n\n.. So in the some case s(such as warnings) this header line won't re-print ? Read the docs or the source? Remember this is open source and in this case the module is Perl so don't forget you can have a look there too. Essentially the module caches the warnings, etc. until either you explicitly request they be printed, or until a simulated 'die' (a fatalToBrowser) is called at which time if there are warnings and you asked for them they are also printed. I assume from looking at the source there is no way to prevent a double header print on a 'die' after a header, except just don't do it. theoretically anything coming after the header is printed shouldn't call die anyways, to me that would be an uncaught/unhandle exception which shouldn't happen, that is what testing is for :-)... http://danconia.org On warnings from the docs: MAKING WARNINGS APPEAR AS HTML COMMENTS It is now also possible to make non-fatal errors appear as HTML comments embedded in the output of your program. To enable this feature, export the new warningsToBrowser subroutine. Since sending warnings to the browser before the HTTP headers have been sent would cause an error, any warnings are stored in an internal buffer until you call the warningsToBrowser() subroutine with a true argument: use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use CGI qw(:standard); print header(); warningsToBrowser(1); You may also give a false argument to warningsToBrowser() to prevent warnings from being sent to the browser while you are printing some content where HTML comments are not allowed: warningsToBrowser(0);# disable warnings print script type=\text/javascript\!--\n; print_some_javascript_code(); print //--/script\n; warningsToBrowser(1);# re-enable warnings Note: In this respect warningsToBrowser() differs fundamentally from fatalsToBrowser(), which you should never call yourself! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How does CGI.pm handles Content-type: text/html\n\n ?
On Tuesday, Jul 29, 2003, at 18:36 US/Pacific, LI NGOK LAM wrote: [..] So.. if I create my own style of fatalsToBrowser. Is that possible to do in this way : [..] The reason that 'fatalsToBrowser' and the rest came about is because many perl modules are built on 'die' or 'Carp'. And that 'die' would make the foo.cgi code 'exit abruptly' and that would generate a 500 error. So if the code you are building on does not do a 'die', 'Carp', 'Croak' - then you really do not need to 'worry about it'. What you will want to learn about is how to set a local signal handler - if you want to write your own. I built some stuff ontop of some code that I knew had a series of places where it would invoke 'die' - since that code was not 'designed for the web' and in those case 'dying' was a good thing - so the wrapper call solves it: sub wrapper_call { my ($me,$host_port,$uri,$q) = @_; our ($page,$h) ; our $wrapper_flag = 0; our $bytes_read = 0; eval { local $SIG{'__DIE__'} = sub { $wrapper_flag = 1;} ; ($bytes_read, $page, $h ) = get_from_server($host_port, $uri, $q); }; return({ run_time_error = Problems connecting to $host_port got status: $@ } ) if ( $wrapper_flag ); return({ run_time_error = Server $host_port Returned: $h-{dtk_status}}) if ($h-{dtk_status} !~ /OK/); return $page if ($bytes_read); \$page; } # end of wrapper_call In this case the caller either gets the reference to the page, or a reference to a hash, that has the 'run_time_error' message in it... This way if the caller wants to report out the error case then they can do that, or they can also decide that they do not care that the error occurred, and go on to some other strategy... ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]