LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-16-2004, 10:25 AM   #1
kvasarnomad
LQ Newbie
 
Registered: Sep 2003
Location: Sweden
Distribution: Ubuntu x86_64, Debian, BatBox MIPS, Ubuntu x86
Posts: 22

Rep: Reputation: 15
Question what to do with -> ' <- in SQL?


In a database I done i included a comment colum
but when I tested it and wrote as comment:
-> I haven't got it to work <-
the entry wasn't added
and I realized why it is the -> ' <- in dosen't
how should I do if one writes a word with ' in?

Im using PHP and MySQL

here is the sql syntax thats troubling me when $comment="I haven't got it to work";
Code:
$insertcard="INSERT INTO cards(brand, type, name, comp, comment) VALUES('$brand', '$type', '$name', '$comp', '$comment')";
 
Old 10-16-2004, 10:32 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
does this look familiar?

http://www.webmasterstop.com/tutoria...c-quotes.shtml

and in brief. use the addslashes() funciton
 
Old 10-16-2004, 10:37 AM   #3
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Try escaping with addslashes - replace $comment with:
addslashes($comment)
 
Old 10-16-2004, 10:51 AM   #4
kvasarnomad
LQ Newbie
 
Registered: Sep 2003
Location: Sweden
Distribution: Ubuntu x86_64, Debian, BatBox MIPS, Ubuntu x86
Posts: 22

Original Poster
Rep: Reputation: 15
Ok I used the addslashes on $comment and now it works!
thanks!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sql naflan Programming 6 11-13-2005 11:53 PM
sql help mifan Linux - Software 5 09-07-2005 12:54 AM
Migrating from MS-SQL server to My-SQL emailssent Linux - Networking 2 02-07-2005 02:20 PM
my sql................ apenguinlinux Programming 2 01-24-2005 10:39 PM
Which SQL is suitable for EMbedded SQL on C? hk_michael Programming 4 01-10-2005 05:07 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration