[SOLVED] Watermaking loop problem
Posted: Sat Sep 10, 2005 6:45 pm
Hi I am trying to set up a loop with my website that marks certian images it works for the first loop but when it gos to the next picture I get this error:
Fatal error: Cannot redeclare mergepix() (previously declared in c:\******\*****\*****.php:60) in c:\*****\*****\*******.php on line 60
Warning: Unknown: 1 result set(s) not freed. Use mysql_free_result to free result sets which were requested using mysql_query() in Unknown on line 0
which is line 25 of the code I posted. Question is is there a command to reuse mergepix?
Fatal error: Cannot redeclare mergepix() (previously declared in c:\******\*****\*****.php:60) in c:\*****\*****\*******.php on line 60
Warning: Unknown: 1 result set(s) not freed. Use mysql_free_result to free result sets which were requested using mysql_query() in Unknown on line 0
which is line 25 of the code I posted. Question is is there a command to reuse mergepix?
Code: Select all
<?php
// Line code 29 to 140 to add sold watermark if vehicle sold
if($row_rs_stock['status'] == "Y") {
$sourcefile = "images/".$picname;
$insertfile = 'images/sold.jpg';
$targetfile = "images/S_".$picname;
$transition = '50';
$pos = '0';
//$sourcefile = Filename of the picture into that $insertfile will be inserted.
//$insertfile = Filename of the picture that is to be inserted into $sourcefile.
//$targetfile = Filename of the modified picture.
//$transition = Intensity of the transition (in percent)
//$pos = Position where $insertfile will be inserted in $sourcefile
// 0 = middle
// 1 = top left
// 2 = top right
// 3 = bottom right
// 4 = bottom left
// 5 = top middle
// 6 = middle right
// 7 = bottom middle
// 8 = middle left
//
//
function mergePix($sourcefile,$insertfile, $targetfile, $pos=0,$transition=50)
{
//Get the resource id?s of the pictures
$insertfile_id = imageCreateFromJPEG($insertfile);
$sourcefile_id = imageCreateFromJPEG($sourcefile);
//Get the sizes of both pix
$sourcefile_width=imageSX($sourcefile_id);
$sourcefile_height=imageSY($sourcefile_id);
$insertfile_width=imageSX($insertfile_id);
$insertfile_height=imageSY($insertfile_id);
//middle
if( $pos == 0 )
{
$dest_x = ( $sourcefile_width / 2 ) - ( $insertfile_width / 2 );
$dest_y = ( $sourcefile_height / 2 ) - ( $insertfile_height / 2 );
}
//top left
if( $pos == 1 )
{
$dest_x = 0;
$dest_y = 0;
}
//top right
if( $pos == 2 )
{
$dest_x = $sourcefile_width - $insertfile_width;
$dest_y = 0;
}
//bottom right
if( $pos == 3 )
{
$dest_x = $sourcefile_width - $insertfile_width;
$dest_y = $sourcefile_height - $insertfile_height;
}
//bottom left
if( $pos == 4 )
{
$dest_x = 0;
$dest_y = $sourcefile_height - $insertfile_height;
}
//top middle
if( $pos == 5 )
{
$dest_x = ( ( $sourcefile_width - $insertfile_width ) / 2 );
$dest_y = 0;
}
//middle right
if( $pos == 6 )
{
$dest_x = $sourcefile_width - $insertfile_width;
$dest_y = ( $sourcefile_height / 2 ) - ( $insertfile_height / 2 );
}
//bottom middle
if( $pos == 7 )
{
$dest_x = ( ( $sourcefile_width - $insertfile_width ) / 2 );
$dest_y = $sourcefile_height - $insertfile_height;
}
//middle left
if( $pos == 8 )
{
$dest_x = 0;
$dest_y = ( $sourcefile_height / 2 ) - ( $insertfile_height / 2 );
}
//The main thing : merge the two pix
imageCopyMerge($sourcefile_id, $insertfile_id,$dest_x,$dest_y,0,0,$insertfile_width,$insertfile_height,$transition);
//Create a jpeg out of the modified picture
imagejpeg ($sourcefile_id,"$targetfile");
}
mergePix($sourcefile, $insertfile, $targetfile, $pos, $transition);
// echo "<img src=\"$targetfile\">";
}
?>
<?php
if ($row_rs_stock['leather'] == "Y") {
$optionst = ($optionst . "Leather Interior, ");
}
if ($row_rs_stock['AC'] == "Y") {
$optionst = ($optionst . "Air Conditioning, ");
}
if ($row_rs_stock['2dr'] == "Y") {
$optionst = ($optionst . "2 Door, ");
}
if ($row_rs_stock['3dr'] == "Y") {
$optionst = ($optionst . "3 Door, ");
}
if ($row_rs_stock['4dr'] == "Y") {
$optionst = ($optionst . "4 Door, ");
}
if ($row_rs_stock['5dr'] == "Y") {
$optionst = ($optionst . "5 Door, ");
}
if ($row_rs_stock['atuo_trans'] == "Y") {
$optionst = ($optionst . "Automatic Transmission, ");
}
if ($row_rs_stock['stndrd_trans'] == "Y") {
$optionst = ($optionst . "Standard Transmission, ");
}
if ($row_rs_stock['2WhDrive'] == "Y") {
$optionst = ($optionst . "2 Wheel Drive, ");
}
if ($row_rs_stock['4WhDrive'] == "Y") {
$optionst = ($optionst . "4 Wheel Drive, ");
}
if ($row_rs_stock['FWDrive'] == "Y") {
$optionst = ($optionst . "Front Wheel Drive, ");
}
if ($row_rs_stock['AWDRive'] == "Y") {
$optionst = ($optionst . "All Wheel Drive, ");
}
if ($row_rs_stock['ABS'] == "Y") {
$optionst = ($optionst . "ABS, ");
}
if ($row_rs_stock['PowerBrakes'] == "Y") {
$optionst = ($optionst . "Power Brakes, ");
}
if ($row_rs_stock['TiltSteering'] == "Y") {
$optionst = ($optionst . "Tilt Steering, ");
}
if ($row_rs_stock['PowerSteering'] == "Y") {
$optionst = ($optionst . "Power Steering, ");
}
if ($row_rs_stock['PowerLocks'] == "Y") {
$optionst = ($optionst . "Power Locks, ");
}
if ($row_rs_stock['PowerMirrors'] == "Y") {
$optionst = ($optionst . "Power Mirrors, ");
}
if ($row_rs_stock['PowerSeats'] == "Y") {
$optionst = ($optionst . "Power Seats, ");
}
if ($row_rs_stock['PowerWindows'] == "Y") {
$optionst = ($optionst . "Power Windows, ");
}
if ($row_rs_stock['SunRoof'] == "Y") {
$optionst = ($optionst . "Sun Roof, ");
}
if ($row_rs_stock['AM'] == "Y") {
$optionst = ($optionst . "AM Radio, ");
}
if ($row_rs_stock['AM_FM'] == "Y") {
$optionst = ($optionst . "AM/FM Radio, ");
}
if ($row_rs_stock['Cassette'] == "Y") {
$optionst = ($optionst . "Cassette, ");
}
if ($row_rs_stock['CD'] == "Y") {
$optionst = ($optionst . "CD Player, ");
}
if ($row_rs_stock['DVD'] == "Y") {
$optionst = ($optionst . "DVD Player, ");
} ?>
<?php
$length=strlen($optionst);
$length=$length-2;
$option = substr($optionst, 0, $length);
?>