[PHP] Die Page, Die! (Was: Preview button to show PDF without submitting post data?)
PHP List, Okay, so I've got a nice situation where a form has a preview button as well as a submit button. When the user presses Submit, the page reloads, and it emails a PDF. If the user presses Preview, it launches a new page in a new window, and also outputs a PDF directly to the user so they can review it. All good, but I don't need that second window open once the PDF has been shown to the user. For some reason I can't kill that second window. I've tried two methods. Killing it with PHP, and killing it with JavaScript. Here's the PHP version: if (isset($_POST['preview'])) { $pdf-Output(preview.pdf, D); die(PDF プレビュー出しました / PDF Preview Displayed); } Here's the JavaScript version: if (isset($_POST['preview'])) { $pdf-Output(preview.pdf, D); echo 'script type=text/javascriptjavascript:self.close();/script'; } But in either case, I keep getting that second page coming out, with the whole form rendered all over again. How can I kill a page? Once the PDF is rendered, I don't need it. I'd be okay if it came down to the browser then closed, but it would be better if the server sent the PDF and didn't send the page. Any advice would be much appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] die function
Hi all, I have a machine that must insert in cron in a mysql db in another remote machine. The problem is that I cannot know if the connection in the first machine (adsl) go down because no entry in the machine log is generated. I would like to redirect the die function in a e-mail that say me what happens. I found a script ?php function die_script($errmsg) { print $errmsg . /body/html; die; } ? and I tried to insert a mail() before die function but I cannot call the function in this way: or die(Connection failed: . die_script()); But no email is generated. How can I do? Thanks Barbara -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] php die function for MySQL connection errors
On 14 August 2004 15:50, raditha dissanayake wrote: Ford, Mike [LSS] wrote: (And, BTW, the HTTP definition says that the Location: header should specify a full absolute URL, so that should be: header(Location: http://your.server.name/path/to/errors/servererror.php;); are you sure? Yes. In fact, I was too conservative -- the HTTP RFC says it *must*. See: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30 and http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.2 Just because many browsers accept and process a non-standard header is no reason to write non-standard headers... ;) Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php die function for MySQL connection errors
Ford, Mike [LSS] wrote: On 14 August 2004 15:50, raditha dissanayake wrote: Ford, Mike [LSS] wrote: (And, BTW, the HTTP definition says that the Location: header should specify a full absolute URL, so that should be: header(Location: http://your.server.name/path/to/errors/servererror.php;); are you sure? Yes. In fact, I was too conservative -- the HTTP RFC says it *must*. See: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30 and http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.2 Just because many browsers accept and process a non-standard header is no reason to write non-standard headers... ;) Thanks mike, just when i started to think i was an expert in this field you burst my ego :-) -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 128 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php die function for MySQL connection errors
Hi, I have a quick question about using the PHP die() function. I'm building a site around a MySQL database, and when I connect to the database from a PHP page I use the following code: $connection = mysql_connect($host, $user, $password) or die(Error connecting to SQL server); $db = mysql_select_db($database, $connection) or die('Error connecting to database); Simple enough so far right? So if there is a problem connecting in anyway, an error message appears. What I want though is to redirect to a properly separate error page, rather than just have a basic text mesage. I changed the code to this: $connection = mysql_connect($host, $user, $password) or die(Error connecting to SQL server); $db = mysql_select_db($database, $connection) or header('Location: ../errors/databaseselect.php'); Which works fine (tested by deliberately misnaming database so it can't find it). However if I then use the same approach for the server connection error, like below, it doesn't work. $connection = mysql_connect($host, $user, $password) or header('Location: ../errors/servererror.php'); $db = mysql_select_db($database, $connection) or header('Location: ../errors/databaseselect.php'); I get a variety of error messages dependant on what I tweek to try and make it work. I've tried all I can think of, and I've tried putting the header function inside a die function to no avail. I don't understand why it works for the database connect error but not the server error. If anyone has any suggestions as to what the problem is or how I could improve my technique I'd love to know. I'm sure I can't be the only person who has wanted to do something like this, but I can't find any references online to anything other than simple text error messages. I'm relatively new to PHP but not programming in general so please don't be afraid to fire big words at me. Thanks in advance! John G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php die function for MySQL connection errors
John Gostick wrote: Hi, I have a quick question about using the PHP die() function. I'm building a site around a MySQL database, and when I connect to the database from a PHP page I use the following code: $connection = mysql_connect($host, $user, $password) or die(Error connecting to SQL server); $db = mysql_select_db($database, $connection) or die('Error connecting to database); you haven't told us what error messages you are getting - however my guess is that your header() call fails because of the error message produced by mysql_connect() if so you can try @mysql_connect($host, $user, $password) instead so that error messages to browser are suppressed ( you can achieve the same by editing your php.in) -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 128 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] php die function for MySQL connection errors
-Original Message- From: John Gostick Sent: 14/08/04 15:19 I have a quick question about using the PHP die() function. [...] I changed the code to this: $connection = mysql_connect($host, $user, $password) or die(Error connecting to SQL server); $db = mysql_select_db($database, $connection) or header('Location: ../errors/databaseselect.php'); Which works fine (tested by deliberately misnaming database so it can't find it). However if I then use the same approach for the server connection error, like below, it doesn't work. $connection = mysql_connect($host, $user, $password) or header('Location: ../errors/servererror.php'); On failure, this causes the header to be sent, but doesn't actually stop execution of your script, so... $db = mysql_select_db($database, $connection) this will now fail because you don't have a valid $connection. or header('Location: ../errors/databaseselect.php'); The bottom line is, whenever you issue a header(Location: ) call, you also need to cause the script to die if your logic demands that -- so the above should be written something like: if (!$connection = mysql_connect($host, $user, $password)): header('Location: ../errors/servererror.php'); die(); endif; if (!$db = mysql_select_db($database, $connection)): header('Location: ../errors/databaseselect.php'); die(); endif; (And, BTW, the HTTP definition says that the Location: header should specify a full absolute URL, so that should be: header(Location: http://your.server.name/path/to/errors/servererror.php;); etc.) Cheers! Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php die function for MySQL connection errors
Ford, Mike [LSS] wrote: (And, BTW, the HTTP definition says that the Location: header should specify a full absolute URL, so that should be: header(Location: http://your.server.name/path/to/errors/servererror.php;); are you sure? -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 128 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] die! die! directory!
Help! I've been beating on a problem all day and think I've isolated the problem to the following line: print input type=image src=./maps/map1.jpg name=coordinate ; If I call the statement as is, I get a little red x where my map should be. In earlier calls to the same directory, I can get a server error, misconfiguration... if I change the line to: print input type=image src=map1.jpg name=coordinate ; I see the image. is there a way to declare the path before asking for the file, or a better way to state the file location. Any help will be greatly appreciated. Hugh
[PHP] Die
Hi, If I use die or exit() it break execution of php script but also browswer stop parsing html code. How to avoid this? Regards.Max. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Die
Hi, If I use die or exit() it break execution of php script but also browswer stop parsing html code. How to avoid this? Use proper error handling instead of die()? Let's face it, die() is for when your script needs to, well, die Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]