[PHP] Re: Image and variable
Try this: ?php $myimage = http://pear.php.net/gifs/pearsmall.gif;; echo 'img src=$myimage'; ? Probably you are not initializing the $myimage var. To see if the html generated is ok, you can use your browser view source capability. Henri marc wrote: Hello, I would like to use a variable instead of an image file name in a html page with this instruction: ?php echo 'img src=$myimage'; ? I tried but the image doesn't show up. Is it impossible or do I do something wrong? My goal is to have a random image print in the page, that's why I want to use a variable. Thank you for your good advices. Vous manquez despace pour stocker vos mails ? Yahoo! Mail vous offre GRATUITEMENT 100 Mo ! Crez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/ Le nouveau Yahoo! Messenger est arriv ! Dcouvrez toutes les nouveauts pour dialoguer instantanment avec vos amis. A tlcharger gratuitement sur http://fr.messenger.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Image and variable
Henri marc [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello, I would like to use a variable instead of an image file name in a html page with this instruction: ?php echo 'img src=$myimage'; ? I tried but the image doesn't show up. Is it impossible or do I do something wrong? My goal is to have a random image print in the page, that's why I want to use a variable. Thank you for your good advices. Variables in single-quoted strings are not evaluated. Either user double quotes or concatination: echo img src=\$myimage\; or echo 'img src=' . $myimage . ''; Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Image and variable
$myimage = 'hi.gif'; echo img src='$myimage'; Henri marc wrote: Hello, I would like to use a variable instead of an image file name in a html page with this instruction: ?php echo 'img src=$myimage'; ? I tried but the image doesn't show up. Is it impossible or do I do something wrong? My goal is to have a random image print in the page, that's why I want to use a variable. Thank you for your good advices. Vous manquez despace pour stocker vos mails ? Yahoo! Mail vous offre GRATUITEMENT 100 Mo ! Crez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/ Le nouveau Yahoo! Messenger est arriv ! Dcouvrez toutes les nouveauts pour dialoguer instantanment avec vos amis. A tlcharger gratuitement sur http://fr.messenger.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Image and variable
Hello, Variables in single-quoted strings are not evaluated. Either user double quotes or concatination: Thank you very much all for your help, specially Kevin Waterson for his complete program. It was simple, I always make some mistakes with those quotes :-( Another problem still related to those images. I have done that just as a test. Its' very simple but I really don't know why, the result is always the same picture. ?php $random=MT_RAND(1,2); echo $randombr; if ($random=1) { $image='pic.gif'; } if ($random=2) { $image='pic2.gif'; } echo $image; echo img src='$image'; ? Before I used 'if... else' but it wasn't working so I made a test with a second 'if'. I print the result of the variable to be sure that the number is really different, but anyway the picture is always the same. Why, why, why? Vous manquez despace pour stocker vos mails ? Yahoo! Mail vous offre GRATUITEMENT 100 Mo ! Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/ Le nouveau Yahoo! Messenger est arrivé ! Découvrez toutes les nouveautés pour dialoguer instantanément avec vos amis. A télécharger gratuitement sur http://fr.messenger.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Image and variable
On 10 August 2004 15:55, Henri Marc wrote: Hello, Variables in single-quoted strings are not evaluated. Either user double quotes or concatination: Thank you very much all for your help, specially Kevin Waterson for his complete program. It was simple, I always make some mistakes with those quotes :-( Another problem still related to those images. I have done that just as a test. Its' very simple but I really don't know why, the result is always the same picture. ?php $random=MT_RAND(1,2); echo $randombr; if ($random=1) { You mean == (comparison) not = (assignment). Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Image and variable
On Tuesday 10 August 2004 22:54, Henri Marc wrote: Variables in single-quoted strings are not evaluated. Either user double quotes or concatination: Thank you very much all for your help, specially Kevin Waterson for his complete program. It was simple, I always make some mistakes with those quotes :-( That's why view (HTML) source should be part of your debugging procedure. Another problem still related to those images. You should always start a new thread when asking about something different. I have done that just as a test. Its' very simple but I really don't know why, the result is always the same picture. ?php $random=MT_RAND(1,2); echo $randombr; if ($random=1) { Because you're assigning the value 1 to the variable $random. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Small change can often be found under seat cushions. -- One of Lazarus Long's most penetrating insights */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php