Connecting Tech Pros Worldwide Forums | Help | Site Map

Quoting PHP code in a .php file???

Georges Trottier
Guest
 
Posts: n/a
#1: Jul 17 '05
I am new to PHP and I want to quote the followong content into a Web page

<html>
<head><title>Connect Server</title></head>
<body>
<?
$link = mysql_connect("localhost",$_POST['username'],$_POST['password'])or
die("Connect Error: ".mysql_error());
print "Successfully connected.\n";
mysql_close($link);
?>
</body>
</html>

The Web page is generated by a xxx.php file and what I want to be q quote is
executed rather than displayed. I have tried to surround it with block
formatting HTML elements such as <blockquote> or <pre> but the PHP code
surrounded by "<?" and "?>" always get executed and throws errors.

How can I simply quote it and display it on the page?

Thank yoy

Georges





Pedro Graca
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Quoting PHP code in a .php file???


Georges Trottier wrote [edited]:[color=blue]
> How can I simply quote and display [HTML with PHP code] on the page?[/color]

How do you get the contents you're trying to display?

Try these:
http://www.php.net/htmlentities
http://www.php.net/highlight_file

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
John Dunlop
Guest
 
Posts: n/a
#3: Jul 17 '05

re: Quoting PHP code in a .php file???


Georges Trottier wrote:
[color=blue]
> <html>
> <head><title>Connect Server</title></head>
> <body>
> <?
> $link = mysql_connect("localhost",$_POST['username'],$_POST['password'])or
> die("Connect Error: ".mysql_error());
> print "Successfully connected.\n";
> mysql_close($link);
> ?>
> </body>
> </html>[/color]
[color=blue]
> How can I simply quote it and display it on the page?[/color]

In HTML, you must change the '<'s so that the browser does
not interpret them as the beginnings of markup. The built-
in function htmlspecialchars serves this purpose. It
converts so-called special characters to their entity
references.

http://www.php.net/manual/en/functio...ecialchars.php

--
Jock
Closed Thread


Similar PHP bytes