scm22ri 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! Quote 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. Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/271674-php-image-syntax-question/#findComment-1397855 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.