Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2006
    Posts
    311
    Thanks
    0
    Thanked 1 Time in 1 Post

    Mysql giving error with '

    I have built a php script that inserts data into a mysql table but everytime I try and insert data with an ' it returns an error:

    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 's', 'step')' at line 2

    in this particular case I was trying to insert the word "dave's"

    What's going on? any help woud be appreciated Thanks

  • #2
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    you need to escape your quotes.
    If you're using PHP then wrap your values in mysql_real_escape_string() - it will escape all characters that will throw up these errors.
    If you dont have mysql_real_escape_string - try addslashes()

    http://uk.php.net/mysql_real_escape_string
    http://uk.php.net/manual/en/function.addslashes.php

  • #3
    Regular Coder
    Join Date
    Aug 2006
    Posts
    311
    Thanks
    0
    Thanked 1 Time in 1 Post
    That did it. Thank you very much


  •  

    Posting Permissions

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