Guest Posted December 6, 2012 Share Posted December 6, 2012 Hi Everyone, I'm trying to echo out an image in a while loop but my syntax is wrong. What am I doing wrong? echo '<div align="center"><img src="photos/<?php echo rand(1,n);?>.jpg" alt="Random Image" /></div></td>'; Thanks! Link to comment https://forums.phpfreaks.com/topic/271674-php-image-syntax-question/ Share on other sites More sharing options...
Jessica Posted December 6, 2012 Share Posted December 6, 2012 You're already in PHP, you can't open another PHP tag. Use concatenation or make those 3 separate lines of code. Link to comment https://forums.phpfreaks.com/topic/271674-php-image-syntax-question/#findComment-1397854 Share on other sites More sharing options...
Jessica Posted December 6, 2012 Share Posted December 6, 2012 Also n is going to be undefined. You probably mean $n. Link to comment https://forums.phpfreaks.com/topic/271674-php-image-syntax-question/#findComment-1397855 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.