backslash problem

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

    backslash problem

    Hi group !

    I'm new to PHP but I like it a lot !

    I created a textbox form to publish news on my site ...
    It's a simple textbox with an submit button.
    When the button is pressed the data in the textbox is stored in mysql .

    When I wan't to retrieve the stored text and display it through PHP some
    words aren't displayed right.
    An example : Isn't is displayed as Isn\'t

    The solved the \n problem with the nl2br function.

    Is there a function for my backslash problem ?

    thanks,



  • Dylan Parry

    #2
    Re: backslash problem

    = poster = wrote:
    Is there a function for my backslash problem ?
    You're looking for the stripslashes() function. See


    --
    Dylan Parry
    http://electricfreedom.org | http://webpageworkshop.co.uk

    Programming, n: A pastime similar to banging one's head
    against a wall, but with fewer opportunities for reward.

    Comment

    • = poster =

      #3
      Re: backslash problem

      Thanks,

      I'll give it a try .


      "Dylan Parry" <usenet@dylanpa rry.comwrote in message
      news:4p6j2bFhfu lgU1@individual .net...
      >= poster = wrote:
      >
      >Is there a function for my backslash problem ?
      >
      You're looking for the stripslashes() function. See

      >
      --
      Dylan Parry
      http://electricfreedom.org | http://webpageworkshop.co.uk
      >
      Programming, n: A pastime similar to banging one's head
      against a wall, but with fewer opportunities for reward.

      Comment

      • = poster =

        #4
        Re: backslash problem

        Thanks Dylan it works !

        "= poster =" <nomail@nomail. spamwrote in message
        news:452e1922$0 $1133$ba620e4c@ news.skynet.be. ..
        Thanks,
        >
        I'll give it a try .
        >
        >
        "Dylan Parry" <usenet@dylanpa rry.comwrote in message
        news:4p6j2bFhfu lgU1@individual .net...
        >>= poster = wrote:
        >>
        >>Is there a function for my backslash problem ?
        >>
        >You're looking for the stripslashes() function. See
        >http://uk2.php.net/stripslashes
        >>
        >--
        >Dylan Parry
        >http://electricfreedom.org | http://webpageworkshop.co.uk
        >>
        >Programming, n: A pastime similar to banging one's head
        >against a wall, but with fewer opportunities for reward.
        >
        >

        Comment

        • Pedro Graca

          #5
          Re: backslash problem

          = poster = wrote:
          I created a textbox form to publish news on my site ...
          It's a simple textbox with an submit button.
          When the button is pressed the data in the textbox is stored in mysql .
          >
          When I wan't to retrieve the stored text and display it through PHP some
          words aren't displayed right.
          An example : Isn't is displayed as Isn\'t
          I suspect your SQL command is something like

          $sql = "insert <table(<column> ) values ('{$_POST['text']}')";

          Your PHP is configured with magic_quotes on.
          Special characters in $_POST['text'] are automatically escaped by PHP
          before the values reach your script.
          When the text box entry is

          This isn't right.

          what PHP sees is

          This isn\'t right.

          This is probably what you want as it avoids the syntax error in

          insert <table(<column> ) values ('This isn't right')
          =============== =============== ====^--------^-------^

          If you try to second guess PHP and addslashes() or
          mysql_real_esca pe_string() without a previous stripslashes() the result
          will be

          insert <table(<column> ) value ('This isn\\\'t right')

          So ... either rely on magic_quotes (bad choice!) or make sure you
          mysql_real_esca pe_string() to unescaped data

          <?php
          $user_data = mysql_real_esca ped_string(
          get_magic_quote s_gpc()
          ? stripslashes($_ POST['text'])
          : $_POST['text']
          );
          $sql = "insert <table(<column> ) values ('$user_data')" ;

          --
          File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot

          Comment

          • Todd

            #6
            Re: backslash problem

            I think I read recently that magic quotes will go away in PHP ver 6.

            If you are building a system for the future you might want to turn off magic
            quotes and use addslashes and stripslashes to secure your POST and GET
            variables.

            You might want to read up on php security. It is generally a good idea to
            check your GETs and POSTs to make sure they are clean of "injection" issues.

            Here is a pretty good article:

            Now, next, and beyond: Tracking need-to-know trends at the intersection of business and technology


            Regards

            "= poster =" <nomail@nomail. spamwrote in message
            news:452e1579$0 $5521$ba620e4c@ news.skynet.be. ..
            Hi group !
            >
            I'm new to PHP but I like it a lot !
            >
            I created a textbox form to publish news on my site ...
            It's a simple textbox with an submit button.
            When the button is pressed the data in the textbox is stored in mysql .
            >
            When I wan't to retrieve the stored text and display it through PHP some
            words aren't displayed right.
            An example : Isn't is displayed as Isn\'t
            >
            The solved the \n problem with the nl2br function.
            >
            Is there a function for my backslash problem ?
            >
            thanks,
            >
            >
            >

            Comment

            Working...