Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Escaping quotes when inserting to database
Old 02-16-2012, 05:25 AM Escaping quotes when inserting to database
Skilled Talker

Posts: 68
Trades: 0
I have the following code that inserts data into a MySQL database.
PHP Code:
$gal_name_insert mysql_real_escape_string($_POST['txt_name']);
mysql_query("INSERT INTO galleries (gal_name)VALUES (\"$gal_name_insert\"); 
When It gets inserted to my local database it shows like
PHP Code:
Best for you best for your pet \"New\" 
This is how I would expect it to be inserted. I would then use
PHP Code:
stripslashes 
on the display page.

When I use the same inset code on my live server it gets inserted without the slashes
PHP Code:
Best for you best for your pet "New" 
Is there a setting or something that strips the slashes on inserting?

Cheers

Wayne
HullBorn is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-17-2012, 10:53 PM Re: Escaping quotes when inserting to database
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,960
Name: Keith Marshall
Location: Connecticut
Trades: 0
PHP Code:
$gal_name_insert mysql_real_escape_string($_POST['txt_name']);
mysql_query("INSERT INTO galleries (gal_name) VALUES ('$gal_name_insert')"
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 02-19-2012, 01:14 PM Re: Escaping quotes when inserting to database
Physicsguy's Avatar
404 - Title not found

Posts: 1,060
Name: Scott Kaye
Location: Ontario
Trades: 0
This is pesky, stupid magic quotes at work here. Happens to me ALL the time. The easiest solution is to use this code to disable it at runtime, or you could just disable it serverside, which is the example above the one in the link.
__________________

Please login or register to view this content. Registration is FREE
Physicsguy is offline
Reply With Quote
View Public Profile Visit Physicsguy's homepage!
 
Old 02-19-2012, 04:41 PM Re: Escaping quotes when inserting to database
Skilled Talker

Posts: 68
Trades: 0
Cheers Physicsguy,

It was magic_quotes. I've turned them off in the php.ini file.
HullBorn is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Escaping quotes when inserting to database
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15758 seconds with 11 queries