Hi@all!

I would like to show personalized pictures. This pictures are shown in an email. In my mysql there is one field for every recipient in it there is a car brand like BWM, Volvo, VW and so on. I want that every recipient gets the picture from his brand. But there are around 80 brands and I don´t want to write all the lines for every brand, I would like to do this automatically even I would need such a code for other personalization with a lot more than 80 pictures.

In the Email there is the img tag: <img src="http://www.mysite.com/brand.php?Brand=%Member:CustomField1%"> where %Member:CustomField1% is the brand

With this code it´s working:

<?php 
$Brand = $_GET['Brand']; 
if ($Brand == 'VW')  
{ $fp = fopen('./images/logo_VW.gif', 'rb'); } elseif ($Brand == 'Volvo') { $fp = fopen('./images/logo_Volvo.gif', 'rb'); } else { $fp = fopen('./images/logo_generic.gif', 'rb'); } header('Content-type: image/gif'); fpassthru($fp); fclose($fp); exit;
?>

but like described above I don´t want to write every brand, so I got a code from a friend, but it´s not working - what is wrong?

<?php 
$Brand = $_GET['Brand']; 
$fp = fopen('./images/logo_'.strtolower($Brand).'.gif', 'rb'); 
header('Content-type: image/gif'); 
fpassthru($fp); 
fclose($fp); 
?>

    Unless you are working on a Windows server, your problem is case.

    $fp = fopen('./images/logo_VW.gif', 'rb');
    vs.
    $fp = fopen('./images/logo_' . strtolower ('VW') . '.gif', 'rb');

    They are not the same. Removing the strtolower () function should fix it up, unless the problem is with the $_GET statement.

    $fp = fopen('./images/logo_' . $Brand . '.gif', 'rb');

      many many thanks, it´s working 🙂

      so now I have another question to this case. By the way, I´m working on a linux server.

      The name of my image files is the brand only e.g. VW.gif, Volvo.gif, ... I renamed only some images to logo_xxx.gif because I guessed there could be some problems.
      With the example above I would have to rename all files to logo_VW.gif and so on. If I change the code to

      $fp = fopen('./images/' . $Brand . '.gif', 'rb');

      without "logo_" in front of the brand it´s not working (it would have been to easy :queasy: ). So I think I need something like a placeholder. Is there a possibility not to rename all the images?

        Write a Reply...