Connecting Tech Pros Worldwide Help | Site Map

Quoting PHP code in a .php file???

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 09:58 AM
Georges Trottier
Guest
 
Posts: n/a
Default Quoting PHP code in a .php file???

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, 09:58 AM
Pedro Graca
Guest
 
Posts: n/a
Default 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, 09:59 AM
John Dunlop
Guest
 
Posts: n/a
Default 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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.