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" />"";?> Quote 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" />'; ?> Quote 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 Quote 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 Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/199746-load-image/#findComment-1048424 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.