Solved

Posting " in string

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

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

thanks,
Floris.
0
Comment
Question by:florisb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

695 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