Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

problem with modifying php script

Links for php scripts

Moderators: macek, egami, gesf

problem with modifying php script

Postby bghodsi » Fri Dec 23, 2011 11:27 am

The following script loads and displays an jpg image called 'children'
When I try to modify the code by inserting css styling the program crashes. After I remove all html coding and save the php program,it fails to load the picture. I am quite puzzled. I am running this on localhost(my computer).

Thanks

<?php

$imagepath="images/children.jpg";

$image=imagecreatefromjpeg($imagepath);

// get image height

$imgheight=imagesy($image);

//allocate color for image caption (white)

$color=imagecolorallocate($image, 255, 255, 255);

//Add text to image bottom

imagestring($image, 5, 100, $imgheight-50, "September 1978", $color);

header('Content-Type: image/jpeg');

imagejpeg($image);

?>
bghodsi
New php-forum User
New php-forum User
 
Posts: 3
Joined: Tue Nov 29, 2011 1:37 pm

Re: problem with modifying php script

Postby mbrother » Sat Dec 24, 2011 5:27 am

And this gets used how? Can you show the "using" page? Your PHP code is designed to be "called" by another page. For example, presume the script you posted is called "generateimg.php". Then you need to have another page (call it MyImageUsingPage.php) where you should have an image tag like:

Code: Select all
<img src="generateimg.php">


to actually render the image you're generating.

If you're putting that PHP script in the middle of a regular page, I could understand why things would not go too well. Is that what you're doing?
mbrother
New php-forum User
New php-forum User
 
Posts: 45
Joined: Thu Sep 15, 2011 1:09 pm


Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.