| mysql connect or die (image) header type png
|
Hitman3266

msg:3588755 | 2:37 pm on Mar 1, 2008 (gmt 0) | im looking to achieve something like this mysql_connect($mysql_server, $mysql_admin, $mysql_pass) or die("<img src='http://site.com/error.png'>"); BUT it doesnt render properly in the browser, unless you click the link i need to include // Create: HEADERS // header("Content-type: image/png"); header ("Cache-Control: max-age=7200") within the DIE command or something, so the browser will take it as an image
|
Birdman

msg:3588757 | 2:43 pm on Mar 1, 2008 (gmt 0) | What do you mean by 'it doesn't render properly'? What exactly happens? It should work fine as you have it.
|
Hitman3266

msg:3588764 | 2:49 pm on Mar 1, 2008 (gmt 0) | no its a dynamic image script, and to fetch it i use '<a href="http://site.com/script.php?name=' . $profile['user'] . '" target="_blank"><img src="http://site.com/script.php?name=' . $profile['user'] . '" alt="' . $profile['user'] . '" border="0" /></a>', now if this user exists, it LOADS fine, but if it cant connect to mysql server, it gives the DIE, and SHOWS THE ALT text, the headers dont get sent during the die command it shows the ALT text, when it LOADS fine it sends the headers cause headers are at the end of the script
|
Hitman3266

msg:3588769 | 2:50 pm on Mar 1, 2008 (gmt 0) | i want on DIE to print an "unavailable" image, but within the die command the headers arent sent and it doesnt know its an image
|
Hitman3266

msg:3588782 | 3:07 pm on Mar 1, 2008 (gmt 0) | the script has // Create: HEADERS // header("Content-type: image/png"); header ("Cache-Control: max-age=7200"); //header ("Pragma: no-cache"); putenv('GDFONTPATH=' . realpath('.')); // PINGS // ImagePng($image); ImageDestroy($image); at the end, the beginning is mysql_connect($mysql_server, $mysql_admin, $mysql_pass) or die("<img src='http://site.com/error.png'>"); i want to show an unavailable.png image, but instead im left with the ALT text from <a href="http://site.com/script.php?name=' . $profile['user'] . '" target="_blank"><img src="http://site.com/script.php?name=' . $profile['user'] . '" alt="' . $profile['user'] . '" border="0" /></a>', something isnt getting passed in the die command
|
Birdman

msg:3588824 | 4:01 pm on Mar 1, 2008 (gmt 0) | Ok, I think I see what's happening. Since you have already sent the headers, you should just output the raw image instead of putting it in an HTML image tag. mysql_connect($mysql_server, $mysql_admin, $mysql_pass) or die( readfile( 'error.png' ) );
|
Hitman3266

msg:3589095 | 3:25 am on Mar 2, 2008 (gmt 0) | that got it thank you
|
|
|