Solved

Posting " in string

Posted on 2002-04-26
3
196 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now