NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Apostrophe and line break problems

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 05-26-2007, 05:15 AM THREAD STARTER               #1 (permalink)
NamePros Member
Join Date: Jan 2007
Posts: 98
baris22 is an unknown quantity at this point
 



Apostrophe and line break problems


When I try to insert a sentence with an apostrophe or line break to the database I get an error.

PHP Code:

????: NamePros.com http://www.namepros.com/programming/332177-apostrophe-and-line-break-problems.html
{
    
$sql_query "INSERT INTO `filedetails` (`type`,`title` , `description` , `links` ) 
                                          VALUES ('
$chosenFileType','$title','$description','$linksCollection')";
    
    
$query_result mysql_query($sql_query) or die(mysql_error());


this is the code for inserting into the database.

What can I do to solve this problem?


Thanks all.
baris22 is offline  
Old 05-26-2007, 05:56 AM   #2 (permalink)
Domains my Dominion
 
sdsinc's Avatar
Join Date: Aug 2005
Location: Web 1.0
Posts: 9,558
sdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatness
 


Third World Education Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Animal Rescue Animal Cruelty AIDS/HIV Animal Rescue Wildlife Breast Cancer Animal Rescue Wildlife
Hi,
You should really take the time to read this to understand how to escape special characters (and avoid SQL injections problems too):
http://php.net/mysql_real_escape_string
__________________
NameNewsletter.com - free lists of available domain names
ZoneFiles.net (beta) - ccTLD and gTLD droplists
sdsinc is offline  
Old 05-26-2007, 08:58 AM   #3 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
 




yes, always escape your variables.

PHP Code:
$chosenFileType mysql_real_escape_string($chosenFileType);
????: NamePros.com http://www.namepros.com/showthread.php?t=332177
$title mysql_real_escape_string($title);
$description mysql_real_escape_string($description);
$links mysql_real_escape_string($links);

$sql_query "INSERT INTO `filedetails` (`type`,`title` , `description` , `links` ) VALUES ('$chosenFileType','$title','$description','$links  Collection')"
Barrucadu is offline  
Old 05-29-2007, 03:21 AM   #4 (permalink)
NamePros Regular
Join Date: Oct 2006
Posts: 963
neroux has a spectacular aura aboutneroux has a spectacular aura about
 



Originally Posted by Mikor
yes, always escape your variables.
Unless you are having magic_quotes_gpc on and are working on external data.
__________________
Paris loves CityPics

-- Do not let others be treated this way!
neroux is offline  
Old 05-30-2007, 01:35 PM   #5 (permalink)
New Member
Join Date: Mar 2007
Posts: 16
samuofm is an unknown quantity at this point
 



i notice you have two types of apostrophes or single quotes (at least on my screen). Might wanna check that.
samuofm is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 08:17 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger