473,396 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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


Jul 17 '05 #1
2 1556
Georges Trottier wrote [edited]:
How can I simply quote and display [HTML with PHP code] on the page?


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!
Jul 17 '05 #2
Georges Trottier wrote:
<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> How can I simply quote it and display it on the page?


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
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: snacktime | last post by:
I'm used to using the perl DBI and not very familiar with the python DB-API. I am using PyGreSQL. My question is what is the standard way to quote strings in sql queries? I didn't see any...
22
by: Jane Withnolastname | last post by:
I have been using the charset windows-1252 for a while, but it was pointed out to someone else in this group recently that it's a Microsoft creation (I'm sure I'm getting my facts wrong or skewed)...
383
by: John Bailo | last post by:
The war of the OSes was won a long time ago. Unix has always been, and will continue to be, the Server OS in the form of Linux. Microsoft struggled mightily to win that battle -- creating a...
27
by: Ron Adam | last post by:
Hi, I found the following to be a useful way to access arguments after they are passed to a function that collects them with **kwds. class namespace(dict): def __getattr__(self, name): return...
8
by: zhiwei wang | last post by:
I remember that there is a function that could invoke shell command such as "rm" "cp", directly in .c file. But I could not recall its name, and I googled with nothing meaningful. I vaguely...
4
by: Tim Robinson | last post by:
Hi, I generally consider myself competent with the complexities of quoting but I can't figure out postgres at all. I've read the manual and it looks very straightforward but that doesn't accord...
82
by: Edward Elliott | last post by:
This is just anecdotal, but I still find it interesting. Take it for what it's worth. I'm interested in hearing others' perspectives, just please don't turn this into a pissing contest. I'm in...
21
by: Marius Lazer | last post by:
Is it possible to write a macro that single-quotes its argument? #define SOME_MACRO(x) such that SOME_MACRO(foo) expands to 'foo' Thanks, Marius
2
by: seven.reeds | last post by:
Hi, I am not a js expert by any stretch and this might be a perl question more than js but I have to start somewhere so fingers crossed... Ok, I am doing some ajax and have this '<input...
7
by: Steven W. Orr | last post by:
Python has a number of "quoting" 'options' to help """with times when""" one way may be more convenient than another. In the world of shell scripting, I use a technique that I call minimal...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.