Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/190200-simple-script-wont-work-please-help/
Share on other sites

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 />

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. 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.