Solved

Posting " in string

Posted on 2002-04-26
3
216 Views
Last Modified: 2006-11-17
Hi,

How do I insert " into a database? I use mysql.

thanks,
Floris.
0
Comment
Question by:florisb
3 Comments
 
LVL 6

Expert Comment

by:andreif
ID: 6971295
try this to replace " with \"

Don't forget that sometimes PHP requires extra slashes when you compose string:

$sql = "insert .... values (\"here is \\\" char  \")";

in this example \\\" stands for
\\ - slash
\" - quote
so, string will contain only \"
0
 
LVL 2

Expert Comment

by:jpoesen
ID: 6971822
andreif is right.

to make it a bit easier, you can do it like this :

$Title = "Molly the Bear said : \"Wow dude, honey!\""
$SqlQuery = "INSERT INTO Titles VALUES($Title)"

0
 
LVL 5

Accepted Solution

by:
dkjariwala earned 75 total points
ID: 6971996
Basically you need to use addslashes.

Say you have

$check = "hi'hello";

then $check2 = addslashes($check) would give you,
$check2 = "hi\'hello".

JD
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How would I do a website like this? 5 59
maybe no no httpd.conf 6 47
PHP AJAX JSON 2 61
How can I implement a "Select All" with this configuration...? 6 42
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question