470,833 Members | 1,939 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,833 developers. It's quick & easy.

Escape Character & and #

Hi,
Does anyone know the escape character for & and # like in :
Update GDO_INFO_ER set V_COMMENTAIRE='B&A' where V_USERMODIFICATION='bilal123'
or
Update GDO_INFO_ER set V_COMMENTAIRE='B#A' where V_USERMODIFICATION='bilal123'
I would like to insert & and # literally in the table.
I appreciate any help or suggestion.
Thanks oyu
Bils
Jul 17 '05 #1
2 2013
On 25 Jun 2004 05:21:28 -0700, bj****@hotmail.com (Bilal) wrote:
Hi,
Does anyone know the escape character for & and # like in :


echo htmlspecialchars('&') . "<br>";
echo htmlspecialchars('#') . "<br>";

will give you this html-source:

&amp;<br>#<br>

Regards

Marian

--
Tipps und Tricks zu PHP, Coaching und Projektbetreuung
http://www.heddesheimer.de/coaching/
Jul 17 '05 #2
Bilal wrote:
Hi,
Does anyone know the escape character for & and # like in :
Update GDO_INFO_ER set V_COMMENTAIRE='B&A' where V_USERMODIFICATION='bilal123'
or
Update GDO_INFO_ER set V_COMMENTAIRE='B#A' where V_USERMODIFICATION='bilal123'
I would like to insert & and # literally in the table.
I appreciate any help or suggestion.
Thanks oyu
Bils


I am guessing you are trying to get this from a form and insert/update a
MySQL database?
mysql> insert into x values ('B#H&C');
Query OK, 1 row affected (0.07 sec)

mysql> select * from x;
+-------+
| y |
+-------+
| B#H&C |
+-------+
1 row in set (0.00 sec)

The problem is getting it from the form - through PHP to the database...
My testing is successful. what errors do you get?

Code segment that does the insert from the page.. basically takes an SQL
statement from the page and executes it...

$link = mysql_connect('localhost', $USR, $PWD);
if( $link ) {
mysql_select_db( $DB, $link );
if( $sql ) {
$sql = ereg_replace( ";$", "", $sql );
$sql = ereg_replace( "\\\\", "", $sql );
$result = mysql_query( $sql, $link );
.... code for display results of query here
}

form:

<form action="<?=$PHP_SELF?>" method="post">
Enter a SQL statement:
<input type="text" name="sql" size="25" />
<input type="submit" />
</form>

Michael Austin.
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by yawnmoth | last post: by
2 posts views Thread by Bilal | last post: by
2 posts views Thread by Matthew Wieder | last post: by
4 posts views Thread by Guadala Harry | last post: by
7 posts views Thread by Axel Dahmen | last post: by
15 posts views Thread by pkaeowic | last post: by
131 posts views Thread by Lawrence D'Oliveiro | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.