Connecting Tech Pros Worldwide Help | Site Map

Quoting PHP code in a .php file???

  #1  
Old July 17th, 2005, 10:58 AM
Georges Trottier
Guest
 
Posts: n/a
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




  #2  
Old July 17th, 2005, 10:58 AM
Pedro Graca
Guest
 
Posts: n/a

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!
  #3  
Old July 17th, 2005, 10:59 AM
John Dunlop
Guest
 
Posts: n/a

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 Threads
Thread Thread Starter Forum Replies Last Post
nesting JS in echo's Request-1 answers 32 November 11th, 2008 03:45 PM
PHP-Yes, HTML-No --- Why? Lennart Björk answers 59 January 28th, 2006 02:55 PM
DOM doc - simple find element one man army answers 27 January 25th, 2006 07:25 AM
Code Behind vs not tshad answers 171 November 19th, 2005 07:37 AM