Hi

I have created a php script for writing text in a image. Its working fine. But when I include a file it doesnot generate the image. what is the problem? my code is as bello

<?php
header ("Content-type: image/jpeg");
$im = imagecreatefromjpeg("photo.jpg");
$backgroundColor = imagecolorallocate ($im, 255, 255, 255);
$textColor = imagecolorallocate ($im, 0, 0,0);
$sn='s/n:- '.$_GET['serial'];
imagettftext ( $im , 13 , 0 , 290 ,180 , $textColor , 'century.ttf' , 'tushar' );
imagettftext ( $im , 13 , 0 , 330 ,275 , $textColor , 'century.ttf' , $sn );
imagejpeg($im);
?>

the above code works very fine. But when I use below code it doesnot work

<?php
session_start();
include 'sql.php';
header ("Content-type: image/jpeg");
$im = imagecreatefromjpeg("lottery.jpg");
$backgroundColor = imagecolorallocate ($im, 255, 255, 255);
$textColor = imagecolorallocate ($im, 0, 0,0);
$sn='s/n:- '.$_GET['serial'];
imagettftext ( $im , 13 , 0 , 290 ,180 , $textColor , 'century.ttf' , 'tushar' );
imagettftext ( $im , 13 , 0 , 330 ,275 , $textColor , 'century.ttf' , $sn );
imagejpeg($im);
?>

I need to include sql.php file to call functiong and make 'tushar' in line 7 as variable. Please help me

Recommended Answers

All 2 Replies

There are some possibilities:
1. The include cannot find the file
2. The included file has syntax errors
3. The included file outputs some text, which causes the header to fail

Check your error log for more information.

my included sql file code is

<?php
function serial2name($serial){
    return $name;
}
?> 
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.