SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Member
    Join Date
    Feb 2001
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have a question about MySQL!

    I want to implement a submission type method for my website. For users to send different submissions and have it automatically input them into a database. However, I know there's problems with the apostrophe is used in text. How do I automate this so that if the stuff submitted has apostrophes that it will correct this problem and input it in the database? Is there some sort of search feature in Php or MySQL? Any suggestions?

    ALso, I'm not really sure how the eval function in php3 works. Can someone explain this to me? I want to run php in a php script. Basically, I'll be pulling the php code from the database and I want it to work How do you do that?:0

    Thanks for any advise!

    Regards,

    Leo Chan

  2. #2
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Leo,

    The apostrophes should not cause any problems really - are you sure you're not thinking of quotation marks and/or slashes?

    As for the eval() function, you can find information on it below. Seems to me it allows you execute a PHP statement inside of the function's arguments.

    http://www.php.net/manual/en/function-eval.php

    Good luck!

  3. #3
    SitePoint Member
    Join Date
    Feb 2001
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey there!

    Actually I meant apostrophes. I get errors when submitting something when an apostrophe in it.

    For example, if i had a word like: there's

    It would not store into the database. I would either have to add another apostrophe, like: there''s or rewrite the apostrophe in html coding like there’s .

    I want to be able to submit it as: there's

    And have some sort of script or something to change it or whatever. Is there an easier way?

    I don't really understand the eval function from the php.net site. Can anyone explain it ?

    Regards,

    Leo Chan

  4. #4
    SitePoint Evangelist
    Join Date
    May 2000
    Location
    Canada
    Posts
    533
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    before running the query, pass the textfield data through add_slashes()
    cogito, ergo sum

  5. #5
    SitePoint Enthusiast
    Join Date
    Nov 2000
    Location
    Allentown PA
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's probably just a typo, but it's actually just addslashes($string) -- no underscore.

  6. #6
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My bad Leo - I was confusing apostrophes with commas for some odd reason.

    Vinay/Ed are correct - addslashes() should also preserve your line breaks, so when you call stripslashes() before outputting the text, it should remain formatted the way the user entered it for the most part - I only know this thanks to Freddy, and neither of us seems to know why.

  7. #7
    SitePoint Evangelist
    Join Date
    May 2000
    Location
    Canada
    Posts
    533
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ooops, ya, addslashes() .. hehe, i cant remember everything by heart can i ?

    to err is human, as some smart one once said
    cogito, ergo sum

  8. #8
    SitePoint Enthusiast
    Join Date
    Feb 2001
    Location
    Monmouth Junction, NJ
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    isnt it strip slashes? since u want to get rid of those /

  9. #9
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope - he wants to make sure the apostrophes (single-quotes) do not interfere with his SQL queries...using addslashes() will escape them for him - you use stripslashes() when preparing to format the data for display.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •