Jump to content

simple script won't work. Please help


ironside

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. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.