echo $url

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Qaid
Forum Commoner
Posts: 33
Joined: Wed Feb 15, 2006 12:04 pm

echo $url

Post by Qaid »

Hi,

I have this script to watermark an image, and you have to define where the iamges are located.
Then I have set it up so when a folder points to this address domain.com/index.php?id=1

Then it will load from the MySQL database a folder which I have set to $print_folder

Now in the script that I found, where I have to define the folder, but can anyone tell me if this will work? Because i can't seems to get it working..

Code: Select all

$image_path="folder/folder2/'$print_folder'/";

Hope you can help me..

Best Regards
User avatar
elecktricity
Forum Contributor
Posts: 128
Joined: Sun Sep 25, 2005 8:57 pm
Location: Trapped in my own little world.
Contact:

Re: echo $url

Post by elecktricity »

I think you will need to do it like this:

Code: Select all

$image_path = 'folder/folder2/' . $print_folder' . '/';
I could be wrong, but yea I think so
Qaid
Forum Commoner
Posts: 33
Joined: Wed Feb 15, 2006 12:04 pm

Post by Qaid »

No, sorry.. This won't help :(

Another idea I can use?
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

then your problem is deeper than the syntax of your output. show your code and explain why the post above mine won't work
Qaid
Forum Commoner
Posts: 33
Joined: Wed Feb 15, 2006 12:04 pm

Post by Qaid »

Of course...

This is the config file who calls the MySQL data...

Code: Select all

$w_folder= mysql_query('SELECT folder FROM 2k5 WHERE id=\''.(int)$_GET['id'].'\' limit 1') or die(mysql_error()); 
if (!$w_folder) { 
die('Error:' . mysql_error()); 
}
while ($w_folder = @mysql_fetch_array($w_folder)){ 
$print_folder = $w_folder[folder]; 
}

And the watermark file with a include who calls the config file...

Code: Select all

<?php 
// This script will show image with logo on it 
// Supported are PNGs,GIFs,JPEGs 
// ------------------------------------------------------ 
// call it: http://www.domain.com/showimage.php?img=<name> 
// where <name> is name of image... 
// example: 
// http://www.domain.com/showimage.php?img=001.jpg 
// ------------------------------------------------------ 
// You have to set parameters here: 
// ------------------------------------------------------ 
$image_quality="100"; 
// quality of JPEG conpression [0-100] 
// ------------------------------------------------------ 
$image_path="folder/folder2/'.$print_folder'.'/"; 
// path to images 
// examples: 
// $image_path="./images/"; 
// $image_path="../../images/"; 
// ------------------------------------------------------ 
$logo_path="folder/folder2/watermark.png"; 
// path and name of the LOGO image (PNG,GIF,JPEG) 
// examples: 
// $logo_path="./logos/img_logo.png"; 
// $logo_path="../../logos/img_logo.png" 
// ------------------------------------------------------ 
$logo_pos_x="center"; 
// left, right, center 
$logo_pos_y="top"; 
// top, middle, bottom 
// ------------------------------------------------------ 
$error_not_found="File doesn't exists"; 
// where image is not found, show this error text 
$error_not_supported="This image type isn't supported"; 
// where image is not supported, show this error text 
$error_bg_color=array(255,255,255); 
// image background color in RGB - (RED,GREEN,BLUE) 
$error_text_color=array(255,0,0); 
// text color in RGB - (RED,GREEN,BLUE) 
// ------------------------------------------------------ 
//  YOU DON'T HAVE TO EDIT CODE BELOW THIS LINE 
// ------------------------------------------------------ 
// SCRIPT written by Ladislav Soukup, [root@soundboss.cz] 
// ------------------------------------------------------ 
function NewImage($width,$height,$text=""){ 
   global $error_bg_color,$error_text_color; 
   if (function_exists("imagecreatetruecolor")){ 
      if (!@$img=imagecreatetruecolor($width,$height)){ 
         $img=imagecreate($width,$height); 
      } 
   } else { 
      $img=imagecreate($width,$height); 
   } 
   $imgbgcolor=ImageColorAllocate($img,$error_bg_color[0],$error_bg_color[1],$error_bg_color[2]); 
   $imgtextcolor=ImageColorAllocate($img,$error_text_color[0],$error_text_color[1],$error_text_color[2]); 
   imagefilledrectangle($img,0,0,$width,$height,$imgbgcolor); 
   imagestring($img,5,10,10,$text,$imgtextcolor); 
   return($img); 
} 
Header("Content-type: image/jpeg"); 
$exp=GMDate("D, d M Y H:i:s",time()+999); 
Header("Expires: $exp GMT"); 
$rep_from=array("./","../"); 
$rep_to=array("","",); 
$_GET["img"]=str_replace($rep_from,$rep_to,$_GET["img"]); 
$file=$image_path . $_GET["img"]; 
if (file_exists($file)){ 
   $info=getimagesize($file); 
   $width=$info[0]; 
   $height=$info[1]; 
   if ($info[2]==1){ 
      $img=@imagecreatefromgif($file); 
   } else if ($info[2]==2){ 
      $img=@imagecreatefromjpeg($file); 
   } else if ($info[2]==3){ 
      $img=@imagecreatefrompng($file); 
   } else { 
      $width=225; 
      $height=168; 
      $img=NewImage($width,$height,$error_not_supported); 
   } 
} else { 
   $width=225; 
   $height=168; 
   $img=NewImage($width,$height,$error_not_found); 
} 
if (file_exists($logo_path)){ 
   $info=getimagesize($logo_path); 
   $logo_width=$info[0]; 
   $logo_height=$info[1]; 
   if ($info[2]==1){ 
      $img_logo=imagecreatefromgif($logo_path); 
   } else if ($info[2]==2){ 
      $img_logo=imagecreatefromjpeg($logo_path); 
   } else if ($info[2]==3){ 
      $img_logo=imagecreatefrompng($logo_path); 
   } else { 
      $logo_width=120; 
      $logo_height=20; 
      $img=NewImage($logo_width,$logo_height,$error_not_supported); 
   } 
   // positioning - X 
   if ($logo_pos_x=="left"){ 
      $dst_x=10; 
   } else if ($logo_pos_x=="center"){ 
      $dst_x=round(($width-$logo_width)/2); 
   } else if ($logo_pos_x=="right"){ 
      $dst_x=$width-10-$logo_width; 
   } else { 
      $dst_x=round(($width-$logo_width)/2); 
   } 
   // positioning - Y 
   if ($logo_pos_y=="top"){ 
      $dst_y=5; 
   } else if ($logo_pos_y=="middle"){ 
      $dst_y=round(($height-($logo_height/2))/2); 
   } else if ($logo_pos_y=="bottom"){ 
      $dst_y=$height-5-$logo_height; 
   } else { 
      $dst_y=round(($height-($logo_height/2))/2); 
   } 
   imagecopy($img,$img_logo,$dst_x,$dst_y,0,0,$logo_width,$logo_height); 
} 
ImageJpeg($img,"",$image_quality); 
?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Hint: The string you are inserting $print_folder into is a double quote string.
Another: echo $image_path.
Qaid
Forum Commoner
Posts: 33
Joined: Wed Feb 15, 2006 12:04 pm

Post by Qaid »

How can I fix that?
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

http://us3.php.net/echo has some examples of concatenation on example #1, about 2/3rds down.
Post Reply