Escaping Quotes

  • jordonshaw
  • Student
  • Student
  • User avatar
  • Posts: 96
  • Loc: Tennessee

Post 3+ Months Ago

Ok guys, here for some help again :D With MySql if you have a form, you can escape the quotes by using the command mysql_real_escape_string. The problem is, I have MS SQL and not My Sql. This command does not work on MSSql and I can't figure out how to escape the quotes, so that I can post quotes in the database. Can somebody help?

Thanks,
Jordon
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

Have your tried mssql_real_escape_string()?

If that doesn't work try addslashes();
  • jordonshaw
  • Student
  • Student
  • User avatar
  • Posts: 96
  • Loc: Tennessee

Post 3+ Months Ago

Actually mssql_real_escape_string() did not work. That's what I tried at first. I spent several hours working this last night; however, in the end, I found something that would work:

Code: [ Select ]
$cr_name = stripslashes(str_replace("'", "''", ($_POST['cr_name'])));


Basically stripslashes wouldn't work on it own. After research the only thing MSSQL has a issue with is ' and if you double it, by using '' then it will comment it out. So, that's why I used a string replace from ' to ''; however, when I did this, it posted in the Database like jordon\'s and I could not get rid of the slash, unless I used stripslashes, so as you see, that's how I came up with this line of code, which seems to be working great!
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

alright, cool. Glad you got it figured out.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 135 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.