Escape Character & and #

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bilal

    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_USERMODIFICAT ION='bilal123'
    or
    Update GDO_INFO_ER set V_COMMENTAIRE=' B#A' where V_USERMODIFICAT ION='bilal123'
    I would like to insert & and # literally in the table.
    I appreciate any help or suggestion.
    Thanks oyu
    Bils
  • Marian Heddesheimer

    #2
    Re: Escape Character & and #

    On 25 Jun 2004 05:21:28 -0700, bjeewa@hotmail. com (Bilal) wrote:
    [color=blue]
    >Hi,
    >Does anyone know the escape character for & and # like in :[/color]

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

    will give you this html-source:

    &amp;<br>#<b r>

    Regards

    Marian

    --
    Tipps und Tricks zu PHP, Coaching und Projektbetreuun g
    Da ich mich seit einiger Zeit aus der Programmierung von Websites zurückgezogen habe, sind meine Tutorials und Schulungsinhalte nicht mehr länger verfügbar, da sie inzwischen veraltet sind.

    Comment

    • Michael Austin

      #3
      Re: Escape Character &amp; and #

      Bilal wrote:
      [color=blue]
      > Hi,
      > Does anyone know the escape character for & and # like in :
      > Update GDO_INFO_ER set V_COMMENTAIRE=' B&A' where V_USERMODIFICAT ION='bilal123'
      > or
      > Update GDO_INFO_ER set V_COMMENTAIRE=' B#A' where V_USERMODIFICAT ION='bilal123'
      > I would like to insert & and # literally in the table.
      > I appreciate any help or suggestion.
      > Thanks oyu
      > Bils[/color]

      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.

      Comment

      Working...