gobblegob Posted April 26, 2010 Share Posted April 26, 2010 hello coders, This is my first post here, well actually with PHP as i have only been messing with it for 1 week, but i do have good knowledge of vb.net, anyways.... Then problem i have is an extremely basic and embarrassing after i send an email with my script if successful then show one image if unsuccessful show another. This is my code that works... <?php echo $mail_sent ? "An email has been sent to you." : "Mail has failed.";?> This is what i am trying to do.... <?php echo $mail_sent ? "An email has been sent to you.<img src="images/green_tick.gif" width="20" height="20" />" : "Mail has failed.<img src="images/failed.gif" width="20" height="20" />"";?> Link to comment https://forums.phpfreaks.com/topic/199746-load-image/ Share on other sites More sharing options...
oni-kun Posted April 26, 2010 Share Posted April 26, 2010 As i'm sure what is a necessity of programming language, is maintaining the integrety of strings. PHP is based off of C, So it's not too alien, Just escape: <?php echo $mail_sent ? "An email has been sent to you.<img src=\"images/green_tick.gif\" width=\"20\" height=\"20\" />" : "Mail has failed. <img src=\"images/failed.gif\" width=\"20\" height=\"20\" />"; ?> Or of course you can use single quotes, either to wrap or to use within double quotes: <?php echo $mail_sent ? 'An email has been sent to you.<img src="images/green_tick.gif" width="20" height="20" />' : 'Mail has failed.<img src="images/failed.gif" width="20" height="20" />'; ?> Link to comment https://forums.phpfreaks.com/topic/199746-load-image/#findComment-1048391 Share on other sites More sharing options...
Kidd13 Posted April 26, 2010 Share Posted April 26, 2010 Sorry i just re-posted what you said =S beat me to the submit lol =P Link to comment https://forums.phpfreaks.com/topic/199746-load-image/#findComment-1048392 Share on other sites More sharing options...
gobblegob Posted April 26, 2010 Author Share Posted April 26, 2010 Thanks alot guys , so what does the backslash do ? src=\ please dont flame me lol Link to comment https://forums.phpfreaks.com/topic/199746-load-image/#findComment-1048413 Share on other sites More sharing options...
oni-kun Posted April 26, 2010 Share Posted April 26, 2010 Thanks alot guys , so what does the backslash do ? src=\ please dont flame me lol Oh, I came from a VB.NET background from 4-5 years back but must've forgotten how the more simple things were done. A backslash is an escape entity, Well, best I show you a tutorial on them: http://www.htmlite.com/php008.php If you're using double quotes within double quotes, they need to be escaped from the current context, Such as: print "This is a double quote: \" <---"; Dollar signs have precedence in double quotes, so variable can be displayed: $var = "foo"; print "\$var = $var"; //Will print: $var = foo I'd really recommend looking up some basic PHP tutorials such as in Tizag, As you can trust from an ex-.NET programmer C is much different in its syntax than VB. Link to comment https://forums.phpfreaks.com/topic/199746-load-image/#findComment-1048424 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.