xtraCode Posted June 27, 2011 Share Posted June 27, 2011 Greetings! The php script is anomalously ending with the following example. The follow is outputted: '; ?> I am having a tough time finding anything wrong with my PHP script regarding HTML output. Essentially I would like to echo the entire content of HTML found in this snip. References and resources would be excellent. <html> <head> </head> <body> <div id="gallery"> <a href="#" class="show"> <?php echo '<img src="starbattle1.jpg" width="100%" height="200"></a>'; ?> <div class="caption"><div class="content"></div></div> </div> <div class="clear"></div> </body> </html> update, the image file path will be read in from an array. Quote Link to comment https://forums.phpfreaks.com/topic/240559-echoing-long-html-strings/ Share on other sites More sharing options...
conker87 Posted June 27, 2011 Share Posted June 27, 2011 Where is it outputting that? Look in the source to find out where and that'll tell you where in the script the error is. Quote Link to comment https://forums.phpfreaks.com/topic/240559-echoing-long-html-strings/#findComment-1235649 Share on other sites More sharing options...
gizmola Posted June 27, 2011 Share Posted June 27, 2011 You can go into and out of php blocks anytime you want. $head = "Welcome to my site."; ?> Quote Link to comment https://forums.phpfreaks.com/topic/240559-echoing-long-html-strings/#findComment-1235652 Share on other sites More sharing options...
conker87 Posted June 27, 2011 Share Posted June 27, 2011 It appears I got the wrong end of the stick. What you have just typed will work as is. I will elaborate. If you have an if statement here: $id = $_GET['id']; //get the id from the url Then you can end the php tags and use normal html within the if statements: $id = $_GET['id']; if ($id == 1) { ?> The ID is one, hurray! <?php } else if ($id == 2) { ?> Now it's two. <?php } else { ?> Now it's more than 2! Rebel. <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/240559-echoing-long-html-strings/#findComment-1235655 Share on other sites More sharing options...
xtraCode Posted June 27, 2011 Author Share Posted June 27, 2011 This makes sense. Trying what you suggested has not worked. Inspecting the page source revealed this: <div id="gallery"> <a href="#" class="show"> </a>'; ?> <div class="caption"><div class="content"></div></div> </div> You should know the elements in question belong to a Java Script image scroller. The script is not active in this example though, so I am still left confused. Quote Link to comment https://forums.phpfreaks.com/topic/240559-echoing-long-html-strings/#findComment-1235656 Share on other sites More sharing options...
xtraCode Posted June 27, 2011 Author Share Posted June 27, 2011 Here is the updated code. Below is the page source. The php script highlight stops directly before </a>. <html> <head> </head> <body> <div id="gallery"> <a href="#" class="show"> <?php echo '<img src="starbattle.jpg" width="100%" height="200"></a>'; ?> <div class="caption"><div class="content"></div></div> </div> <div class="clear"></div> </body> </html> ----------------------- PAGE SOURCE ---------------------------- <html> <head> </head> <body> <div id="gallery"> <a href="#" class="show"> <?php echo '<img src="starbattle.jpg" width="100%" height="200"></a>'; ?> <div class="caption"><div class="content"></div></div> </div> <div class="clear"></div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/240559-echoing-long-html-strings/#findComment-1235661 Share on other sites More sharing options...
gizmola Posted June 27, 2011 Share Posted June 27, 2011 Please use code or php tags for any future code submissions you have. I'm not sure what problem you are having right now, I don't see any problems with the code. Are you getting an error? Quote Link to comment https://forums.phpfreaks.com/topic/240559-echoing-long-html-strings/#findComment-1235664 Share on other sites More sharing options...
requinix Posted June 27, 2011 Share Posted June 27, 2011 Make sure that - Your file is named .php (unless you have specifically set up something else) - PHP is installed for whatever medium (eg, Apache/IIS module or CGI) Quote Link to comment https://forums.phpfreaks.com/topic/240559-echoing-long-html-strings/#findComment-1235669 Share on other sites More sharing options...
xtraCode Posted June 27, 2011 Author Share Posted June 27, 2011 I am not getting an error ( one that is displayed on the page--when it loads ). Perhaps there is an error log some where I can check? <?php echo 'Testing PHP TAGS'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/240559-echoing-long-html-strings/#findComment-1235670 Share on other sites More sharing options...
xtraCode Posted June 27, 2011 Author Share Posted June 27, 2011 Make sure that - Your file is named .php (unless you have specifically set up something else) - PHP is installed for whatever medium (eg, Apache/IIS module or CGI) I used XAMPP and I am using Apache. The file is indeed a .php file. <?php echo 'code tag test'; ?> I would think some 3rd party has messed with some PHP settings, but none of my other scripts are having this issue. Quote Link to comment https://forums.phpfreaks.com/topic/240559-echoing-long-html-strings/#findComment-1235673 Share on other sites More sharing options...
gizmola Posted June 27, 2011 Share Posted June 27, 2011 The apache error log would have the error most likely. How are you referending the page? Are you using http://localhost/yourscript.php? Quote Link to comment https://forums.phpfreaks.com/topic/240559-echoing-long-html-strings/#findComment-1235685 Share on other sites More sharing options...
xtraCode Posted June 27, 2011 Author Share Posted June 27, 2011 Hi, IMA idiot. Lets close this topic. Thanks for the help everyone. Quote Link to comment https://forums.phpfreaks.com/topic/240559-echoing-long-html-strings/#findComment-1235689 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.