Staredit Network

Staredit Network -> Computers and Technical -> PHP problem
Report, edit, etc...Posted by Doodle77(MM) on 2005-10-30 at 09:59:31
I have been attempting to make a dynamic sig based on my current sig, but with more comics. When i load up the PHP file it just prints "http://localhost/sigimg.php" rather than actually giving me the image.
Here is the code: [codebox]<?php
header('Content-Type: image/jpg');
header('Content-Length: 27998');
//vars
$randval = 10; //rand(0,10);
if ($randval = 10) {
$randval = rand(0,3);
$imag = imagecreatefromjpeg("fullcomics\lg$randval.jpg");
imagejpeg($imag, "",75);
imagedestroy($imag);
} else {
$imag = imagecreate(771,235);
$randval = rand(0,3);
$imagf1 = imagecreatefromjpeg("partcomics\lgf1$randval.jpg");
$randval = rand(0,3);
$imagf2 = imagecreatefromjpeg("partcomics\lgf2$randval.jpg");
$randval = rand(0,3);
$imagf3 = imagecreatefromjpeg("partcomics\lgf3$randval.jpg");
imagecopy ( $imag, $imagf1, 0, 0, 0, 0, 257, 235);
imagecopy ($imag,$imagf2,257,0,0,0,257,235);
imagecopy ( $imag, $imagf3, 514, 0, 0, 0, 257, 235);
imagejpeg($imag);
imagedestroy($imag);
}
?>[/codebox]
Report, edit, etc...Posted by Shmeeps on 2005-10-30 at 11:25:45
Try this instead

.HTACCESS
CODE

<Files *.jpg>
     ForceType application/x-httpd-php
</Files>


randomsig.png
CODE

<?php
header("Content-type: image/jpg");
//vars
$randval = 10; //rand(0,10);
if ($randval = 10) {
$randval = rand(0,3);
$imag = imagecreatefromjpeg("fullcomics\lg$randval.jpg");
imagejpeg($imag, "",75);
imagedestroy($imag);
} else {
$imag = imagecreate(771,235);
$randval = rand(0,3);
$imagf1 = imagecreatefromjpeg("partcomics\lgf1$randval.jpg");
$randval = rand(0,3);
$imagf2 = imagecreatefromjpeg("partcomics\lgf2$randval.jpg");
$randval = rand(0,3);
$imagf3 = imagecreatefromjpeg("partcomics\lgf3$randval.jpg");
imagecopy ( $imag, $imagf1, 0, 0, 0, 0, 257, 235);
imagecopy ($imag,$imagf2,257,0,0,0,257,235);
imagecopy ( $imag, $imagf3, 514, 0, 0, 0, 257, 235);
imagejpeg($imag);
imagedestroy($imag);
}
?>


I didn't check for errors in code, since I'm assuming the only error is the not getting parsed.

The .htaccess tells the server to parse .jpg files as .php files.

Also, the might need to be jpeg, not jpg. I use pngs, so I dunno.

If your doing this on your local apache installation, and you have windows, then you'll need to do this on a web host that has Linux, because windows doesn't support files with no names.
Report, edit, etc...Posted by Doodle77(MM) on 2005-10-30 at 13:04:16
oh yes it does, you just need to tell it to show file extensions.
btw that had the same result.
Report, edit, etc...Posted by RexyRex on 2005-10-30 at 15:28:43
CODE
header('Content-type: image/png');
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
header('Pragma: no-cache');

Should work.
Report, edit, etc...Posted by Doodle77(MM) on 2005-10-31 at 20:32:02
Turns out I didnt have GD, but i installed it and it still doesnt work.
Report, edit, etc...Posted by RexyRex on 2005-11-02 at 19:51:25
Remove the content-type header and look at the error message PHP gives you.
Hell, I'll do it for you.

PHP returned:
QUOTE
Warning: imagecreatefromjpeg(fullcomics\lg2.jpg): failed to open stream: No such file or directory in C:\Apache\Apache2\htdocs\test.php on line 7

Warning: imagejpeg(): supplied argument is not a valid Image resource in C:\Apache\Apache2\htdocs\test.php on line 8

Warning: imagedestroy(): supplied argument is not a valid Image resource in C:\Apache\Apache2\htdocs\test.php on line 9
Most likely because I don't have proper images. You try. tongue.gif
Report, edit, etc...Posted by Doodle77(MM) on 2005-11-03 at 17:50:50
wooooooooooow... i feel dumb, the file extensions were capital they were .JPG -.-
Next Page (1)