Inserting special character like apostrophes with PHP/Mysql

Hi friends,
I have a problem with php/mysql. I have created a form inton a php page with dreamweaver and when i try to fill the form with a string containing apostrophe ( ' ), i have a error. It seems that the insertion is not possible. Could you have any idea for that. I give you the php dreamweaver code and thank you for your help.
<?php require_once('Connections/Mainconnect.php'); ?>
<?php require_once('Zend/Date.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;   
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
if ($theValue=="")
    $theValue="NULL";
else
    $zendDate=new Zend_Date($theValue,"dd/MM/yyyy");
    $theValue="'".$zendDate->toString("yyyy-MM-dd")."'";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  return $theValue;
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE pers_soc_reg SET field1=%s, field2=%s,
                       GetSQLValueString($_POST['field1'], "text"),
                       GetSQLValueString($_POST['field2'], "double"));

"Normally, you canot use mysql_real_escape_string without connection to database"
That is not true at all. Try running the following script.
<?php
if ($_POST['submit']){
$x1=$_POST['test1'];
foreach ($_POST as $key => $value) {
if (!is_array($value)){
$_POST[$key] = mysql_real_escape_string($value);
extract($_POST);
echo "The text after 'becomes' should be escaped (\')<br/>";
echo "$x1 becomes $test1<br/>";
?>
<hr/>
  <form action="#" method="post" />
Enter some text, including an apostrophe: <input name="test1" type="text"><br/>
    <p><input name="submit" value="submit" type="submit"/>
  </form>

Similar Messages

  • How to Insert special character like 'Б б В в Г Д  ж Ğ ğ € ₧ š Ž ž'

    Hi All,
    My database NLS_CHARACTERSET is ABLAUT and my sql client setting is AMERICAN_AMERICA.AL32UTF8.
    when i try to insert the special character like 'Б б В в Г Д ж Ğ ğ € ₧ š Ž ž' in oracle it shows question mark or square box
    can any one help me how to insert the above character and view the same in database while retrieving.
    Thanks in advance.
    By
    Chells

    I'm not sure.
    Perhaps UNISTR() or TO_NCHAR() will be helpful.
    select level, unistr(concat('\', TO_CHAR(Level, 'FM000X'))) from dual connect by level < 300;

  • How to insert special character like trademark and registered mark.

    I have tried using prepared statment, but characters like � (registered mark) are not inserted properly, in fact i tried using some debug statements before inserting. the data that is coming from html form fields it self shows that � - such characters are converted to ? . So on consol instead of � i see ?. How do I make sure that data passing from html form will pass � in a right manner and not ?. Also how do i insert these symbols in database

    What database are you using, and what is the character set use for storage in that database?
    What character set is your HTML page using?
    You may have a character set mismatch somewhere. The registered symbol � is character 174 in Unicode and LATIN-1, so it cannot be displayed using just the ASCII character set.
    If you have the character in a java String, it should be passed to the database properly with a PreparedStatement. Strings are Unicode in java.
    Scott
    http://www.swiftradius.com

  • How to insert special character from Oracle form builder 10g

    Dear all,
    I need help. how to insert special character like 'Superscript or Subscript ' from oracle form builder 10g. I had try in Oracle form builder 6i with press ALT+ASCII code in the text item and it work, but in the oracle form builder 10g this method doesn't work... would you like to help me...somebody please...
    Best Regard,
    Dedy P.T.

    What do you mean by insert ... from Forms Builder? Do you mean you want to add it as text in a string of pl/sql code or as part of boiler plate text (label) or a value on the Property Palette?
    For special characters you would need set NLS_LANG to something that would support the characters you want to use. For the Builder to see the change, you would need to set NLS_LANG to something like:
    NLS_LANG=AMERICAN_AMERICA.UTF8
    This can be done in the Windows Registry or system. As I mentioned, this will only apply to the Builder and will have nothing to do with a running form. For running forms you would need to set this in default.env. As for things like super and sub scripts, these are font formats and not necessarily characters. For the most part, I don't believe these are supported in Forms.

  • Inserting Special Character using SQL*Plus

    I am trying to insert special character like ® using SQL*Plus but it is inserting a .(dot) instead.
    Environment:
    Oracle Enterprise version : 9.2.0.3.0
    Sun Solaris 8
    Any help will be appreciated.
    Regards,
    Nirmalya

    That's the reason I use ASCII values always for special characters.
    SQL> create table sample1(col1 varchar2(50))
      2  /
    Table created.
    SQL> insert into sample1
      2  select 'The temperature outside is 20'||chr(176)||' centigrade' col1
      3  from dual
      4  /
    1 row created.
    SQL> commit
      2  /
    Commit complete.
    SQL> select * from sample1
      2  /
    COL1
    The temperature outside is 20° centigrade
    1 row selected.
    SQL> drop table sample1 purge
      2  /
    Table dropped.
    SQL> Cheers
    Sarma.

  • How to insert special character in sgm file and interprete it without isoents while opening in FM9.0

    I have an sgm file which contains special characters in different languages.
    <!DOCTYPE MANUAL PUBLIC "-//SWE-XXX//DTD XXX MANUAL-DTD 2.0//EN">
    <MANUAL LANG="CS">
    <TITEL>
    Polish characters: &oacute;&ecirc;&iquest;&ntilde;&aelig;&Ntilde;&AElig;&Ecirc;&yen;&Oacute;&pound;
    Czech characters: &eacute;&igrave;&oacute;&iuml;&aacute;&oslash;&egrave;&iacute;&ugrave;&ograve;&uacute;&Og rave;&Igrave;&Eacute;&Oacute;&Uacute;&Ugrave;&Egrave;&Oslash;&Iacute;&Aacute;&Iuml; aacute: &aacute;</TITEL>
    </MANUAL>
    Is there any way to insert special character directly in sgm file, so that it won't have to be interpreted by isoents mapping rules?
    isoent.rwr interpretes oacute as:
    entity "oacute" is fm char 0x00F3;
    But I would like to use 0x00F3 directly in fm file, so that if any additional character is needed - I won't have to update isoent files
    I've tested already:
    &#x00F3;
    &x00F3;
    &0x00F3;
    but with no luck
    Is there anyone who could help me with it?
    I will really appreciate your help
    /Joanna

    Hi Michael. Thank you for your reply.
    There is no declaration within sgm file itself - but while opening the file I use sgml application definition with the following settings:
    Default API client:  FmTranslator
    SGML character encoding:  ISO Latin1
    XML character encoding:  UTF-8
    Namespace: Enable
    CSS2 Preferences:
    Generate CSS2: Disable
    Add Fm CSS Attribute To XML: Disable
    Retain Stylesheet Information: Disable
    Entity locations
    Entity search paths
    C:\Program Files\Adobe\FrameMaker9\Structure\sgml\isoents
    So as you can see, character encoding is set to ISO Latin1 (there is no way to use UTF-8 encoding in sgml files)
    Typing ź or ć in sgm document and opening it with framemaker sgml application - I receive: ¿æ and message: "Non-SGML character found; should have been character reference"
    Everything works fine when I type f.ex.: &x016B; and insert appropriate reference lines into isolat1.rw and isolat1.ent files
    But what I would like to avoid is editing those isoent files each time new character is be needed.

  • Prices with PHP/MySQL

    I want to use numbers from a database as prices. In the database (PHP/MySQL) the structure is "decimal(9,2)". If I put it out with PHP a number like 9.02 is € 9.02 but 9.20 looks like this € 9.2. How do I put prices with PHP/MySQL?
    I hope my question is clear.. Thankx for any further help.

    Use the PHP number_format() function.

  • Why the SAX parser cannot support the special character like "¡"

    I do not understand why the SAX parser cannot support the special character like &iexcl; but it can replace the &quot; &amp; &lt; &gt;   to ", &, <, >, ,, but other characters will be replaced to empty charater.
    can somebody give me any suggestions or solutions. THX.
    Edited by: 844086 on 2011-3-14 上午2:27
    Edited by: 844086 on 2011-3-14 上午2:27

    I quote:
    Alternatively implement an EntityResolver that resolves the desired escapes.You are again an example that people only read/register the first thing written in a post.

  • DIS PDF with special Character like cyrillic or chinese

    Hello,
    does anybody know how I can solve my Problem with PDF-Documents with Special Character which are Checked In (Tcode CV02N)
    If I want to open the file again, it will be downloaded to
    C:\Users\....\AppData\Local\SAP\SAPGUI\tmp\####
    and not with the Special characters.... so SAP says
    File
    C:\.......
    could not be accessed
    So is there any flag to set in the customizing that the downloaded file will be with the correct Name or any note?
    (Our System is a Unicode System)
    (my Laptop has all the Windows updates including the language packages for Russia and China)
    Thanks in advance
    Stephan

    Hello,
    the SAPhttp.exe is in the Folder:
    C:\Program Files (x86)\SAP\FrontEnd\SAPgui\Unicode
    on my laptop
    therefore I think it should be the Unicode Version?

  • Uploading file with special character like ( # , $ or any other special ch)

    Hi All,
    This perform statements then uploads the file from UNIX. Because of the special character in the file this  program fails.
    Please let me resulation as soon as possible .
    Thanks,
    Madhav

    Hi
    Good
    Check the below sdn post on special character.
    https://forums.sdn.sap.com/profile.jspa?userID=3649609
    Thanks
    mrutyun^

  • Problem when displaying images when working  with PHP, mysql and dreamweaver in a brower

    Hey Guys
    I am new to dynamic development but I already did some
    research and tutorials about how to get a dynamic web site working
    with PHP and Mysql in Dreamweaver. I set up a test page to view
    some content on it directly from the mysql database and it worked
    just fine in dreamweaver only when I pressed the
    live data view.
    When I tried to view the same page using the browser preview
    with firefox and internet explorer, plain text from the database
    was correctly displayed on the brower but the images were absent.
    In the mysql database I used the varchar as my picture data
    type field so that I will refer in dreamweaver in the data binding
    panel in the img.src to the picture column of my database.
    I anyone can tell me what am I doing wrong so that my
    pictures are not displayed in the browser when i click the browser
    preview facility in dreamweaver I would be very very and very
    pleased ! :)

    The odds are that it is the way that you have referenced the
    images rather
    than an issue with the database. If you have the images root
    relative like
    this "/images" then they will work in preview, and on the
    webserver, but
    will not view when looking at the file via localhost.
    If possible make the links page relative and then they should
    work fine.
    Paul Whitham
    Certified Dreamweaver MX2004 Professional
    Adobe Community Expert - Dreamweaver
    Valleybiz Internet Design
    www.valleybiz.net
    "mariosal026" <[email protected]> wrote in
    message
    news:ea3nq2$9ol$[email protected]..
    > Hey Guys
    >
    > I am new to dynamic development but I already did some
    research and
    > tutorials
    > about how to get a dynamic web site working with PHP and
    Mysql in
    > Dreamweaver.
    > I set up a test page to view some content on it directly
    from the mysql
    > database and it worked just fine in dreamweaver only
    when I pressed the
    >
    live
    > data view.
    >
    > When I tried to view the same page using the browser
    preview with firefox
    > and
    > internet explorer, plain text from the database was
    correctly displayed on
    > the
    > brower but the images were absent.
    >
    > In the mysql database I used the varchar as my picture
    data type field so
    > that
    > I will refer in dreamweaver in the data binding panel in
    the img.src to
    > the
    > picture column of my database.
    >
    > I anyone can tell me what am I doing wrong so that my
    pictures are not
    > displayed in the browser when i click the browser
    preview facility in
    > dreamweaver I would be very very and very pleased ! :)
    >

  • Not inserting special charactors like in HTMLDocument insertHTML

    hello,
    I want to allow special charactrs to get inserted in HTMLDocument of JtextPane like > < .
    I know I can encode them by ;&gt & ;&lt
    But What if i want to insert a <img src='blabla' > , here the < > tags of img will also get replaced.
    How can we handle this situation?
    thanks
    Ani

    thanx again for replying...
    Here m using ;&gt for gr8er than symb n    ;&lt for less than I this post editor  dont show these charactors.
    You are exactly right about the logic .. I have used RE only .
    but in case of swing module, situation is little different , I am getting a message on which my swing module drives is for ex.
    hi <img src='images/smile.gif'>  where all replacement is already done.
    so here I can insert the above msg directly as HTML using insertHTML but my pbm is what about the charactors like ;&gt ;&lt which are not displaying on the JtextPane HTML Document.
    SPECIALLY WHEN i TRIED TO INSERT THE MESSAGE LIKE
    <note> : I want this <img src='images/smile.gif'>So in insertHTML , the msg displaying is nothing as it starts with ;&gt .
    ;&lt is getting ok but ;&gt giving me pbm.
    any solu'n for this ;&gt?

  • Thinking of learning to build sites with PHP/MySQL

    Is it worth it to invest the time and brain power? I've been
    using Dreamweaver for years. None of my sites really are so large
    that I'm having issues. But, I could see some down the road that
    might be too complex and large.
    I'm having some problems figuring out where to begin. Any
    suggestions on books that specifically deal with Dreamweaver and
    database driven sites?

    David Powers 'Foundation PHP for Dreamweaver 8' is what got
    me started. I
    was able to work through most of it in a weekend. He takes
    you step by step
    on how to set up your computer to run PHP/MySQL, and then you
    build a series
    of increasingly complex projects with each new aspect of
    PHP/MySQL that he
    teaches.
    He has some newer books out, too, if you have a more recent
    version of DW:
    http://foundationphp.com/
    ...Brenda
    "PeteC" <[email protected]> wrote in
    message
    news:g4dn2u$1gh$[email protected]..
    > synterx wrote:
    >> Is it worth it to invest the time and brain power?
    I've been using
    >> Dreamweaver for years. None of my sites really are
    so large that I'm
    >> having issues. But, I could see some down the road
    that might be too
    >> complex and large.
    >>
    >> I'm having some problems figuring out where to
    begin. Any suggestions
    >> on books that specifically deal with Dreamweaver and
    database driven
    >> sites?
    >
    > Anything by David Powers (of this parish) will be an
    exceedingly good
    > investment..
    >
    > Pete.
    > --
    > Peter Connolly
    >
    http://www.kpdirection.com
    > Utah
    >

  • Help with php mysql connect script

    Ok guys im new to php mysql and i'm trying to insert some
    form information in my database. Im using a script from sitepoint
    in which i went through the tutorial did some experiments of my own
    and it worked....
    but now i'm getting this error which i cant figure out....
    Error placing order: You have an error in your SQL syntax;
    check the manual that corresponds to your MySQL server version for
    the right syntax to use near 'order SET product ='1',
    size='medium', color='', quantity = '1' at line 1
    here is the page
    http://vaughntucker.com/imagecon/hats.php
    and this is the script
    <?php
    //default page display
    //connect to database
    $dbcnx = @mysql_connect('p3nl41mysql7.secureserver.net',
    'imagecon', 'Dub*boss_1');
    if (!$dbcnx) {
    echo '<p> Unable to connect to the '. 'database server
    at this time.</p>';
    exit();
    //select database
    if (!@mysql_select_db('imagecon')) {
    exit('<p>Unable to locate the ' .
    'database at this time.</p>');
    //Mysql query add joke
    if (isset($_POST['submit'])) {
    $product = 1;
    $size = $_POST['size'];
    $color = $_POST['color'];
    $quan = $_POST['quantity'];
    $sql = "INSERT INTO order SET
    product ='$product',
    size='$size',
    color='$color',
    quantity = '$quan',
    date = CURDATE()";
    }else{
    echo 'No data submited';
    if (@mysql_query($sql)) {
    echo '<p>Your order has been submited.</p>';
    } else {
    echo '<p>Error placing order: ' .
    mysql_error() . '</p>';
    ?>
    thanks in advance

    $sql = "INSERT INTO order SET
    product ='" . $product . "',
    size='" . $size . "',
    color='" . $color . "',
    quantity = '" . $quan . "',
    I believe there are other more elegant ways to do this, as
    well.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "beatzMalone" <[email protected]> wrote in
    message
    news:[email protected]...
    > Ok guys im new to php mysql and i'm trying to insert
    some form information
    > in
    > my database. Im using a script from sitepoint in which i
    went through the
    > tutorial did some experiments of my own and it
    worked....
    >
    > but now i'm getting this error which i cant figure
    out....
    >
    > Error placing order: You have an error in your SQL
    syntax; check the
    > manual
    > that corresponds to your MySQL server version for the
    right syntax to use
    > near
    > 'order SET product ='1', size='medium', color='',
    quantity = '1' at line 1
    >
    > here is the page
    >
    http://vaughntucker.com/imagecon/hats.php
    >
    > and this is the script
    > <?php
    > //default page display
    > //connect to database
    > $dbcnx = @mysql_connect('p3nl41mysql7.secureserver.net',
    'imagecon',
    > 'Dub*boss_1');
    > if (!$dbcnx) {
    > echo '<p> Unable to connect to the '. 'database
    server at this
    > time.</p>';
    > exit();
    >
    > }
    >
    > //select database
    > if (!@mysql_select_db('imagecon')) {
    > exit('<p>Unable to locate the ' .
    > 'database at this time.</p>');
    > }
    >
    > //Mysql query add joke
    > if (isset($_POST['submit'])) {
    > $product = 1;
    > $size = $_POST['size'];
    > $color = $_POST['color'];
    > $quan = $_POST['quantity'];
    > $sql = "INSERT INTO order SET
    > product ='$product',
    > size='$size',
    > color='$color',
    > quantity = '$quan',
    > date = CURDATE()";
    > }else{
    > echo 'No data submited';
    >
    > }
    > if (@mysql_query($sql)) {
    > echo '<p>Your order has been submited.</p>';
    > } else {
    > echo '<p>Error placing order: ' .
    > mysql_error() . '</p>';
    > }
    >
    >
    >
    > ?>
    >
    > thanks in advance
    >

  • Creating a flash website to work with php & MYSQL for MMORPG

    Hi i have a website which is a gangster MMORPG, it using PHP,
    CSS, HTML and some javascript but however with the amount of game
    similar to mine i want to make it unique so i bought "building
    flash websites for dummies" i have read must of it and understand
    most of it. but however don't really have a clue i it could
    actually work with my website.
    what i want to know is can it work with my current PHP &
    MYSQL, so for example i want to create a logging page with flash to
    replace my old PHP/HTML one this will be my first crack at it. but
    will flash be able to check the MYSQL database and send error
    messages back to the view etc.

    Yeah, this can work... My recommendations would be to read a
    couple articles in the dev center on this topic, that should get
    you started...
    http://www.adobe.com/devnet/flash/articles/flash_databases.html
    http://www.adobe.com/devnet/flash/articles/datawizards.html
    http://www.adobe.com/devnet/flash/articles/ria_dataservices.html

Maybe you are looking for