ironside Posted January 29, 2010 Share Posted January 29, 2010 I'm new to php, and I am having trouble displaying a simple script in my web browser. My php code executes fine but the html tags in my script are treated as text and displayed on the page. This is myscript: <?php print “Opening the connection to the database server< br />”; $link = mysql_connect("localhost", "root", "password"); print " Selecting a database< br />" ; $result = mysql_select_db( "databasename" ) ; if ( $result ) { print " Database selected successfully< br />"; } else { print " There was a problem with the database selection< br />" ; } ?> This is the output: Opening the connection to the database server< br /> Selecting a database< br /> Database selected successfully< br /> Why are the html tags being displayed in the output? I'm using: php 5.3.1 apache 2.2.12 mysql 5.0.88 on fedora 10. Any help would be much appreciated. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/190200-simple-script-wont-work-please-help/ Share on other sites More sharing options...
premiso Posted January 29, 2010 Share Posted January 29, 2010 Not exactly sure why they are displayed on the page (I guess it could be hte browser) But a valid HTML tag does not have a space before the tag name: < br /> as you can see you have a space before the b. The valid way would be doing it without a space: <br /> Quote Link to comment https://forums.phpfreaks.com/topic/190200-simple-script-wont-work-please-help/#findComment-1003467 Share on other sites More sharing options...
ironside Posted January 29, 2010 Author Share Posted January 29, 2010 Not exactly sure why they are displayed on the page (I guess it could be hte browser) But a valid HTML tag does not have a space before the tag name: < br /> as you can see you have a space before the b. The valid way would be doing it without a space: <br /> Lol. I knew it was something simple. I copied and pasted that example from some where not realizing the spaces in the line break tag. I removed the spaces and now it works fine. Thank you for your help. Quote Link to comment https://forums.phpfreaks.com/topic/190200-simple-script-wont-work-please-help/#findComment-1003476 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.