[PHP-DB] MySQL and apostrophes, interesting problem. 42082

2002-03-10 Thread Nick Patsaros

I'm working with a simple form which submits field
data to a MySQL database.  This is for the purpose of
generating a dynamic news page for my site. 
Interestingly enough I've found that any time I try to
submit data that contains an apostrophe ' it gives
me an error and will not send the data (any of it) to
the database. 

How can I change my database query, or escape out
apostrophes?  I'm looking for the easiest fix out
there of course.  Below is my current DB query. I
realize I'm using apostrophes for my variables... is
this acceptable syntax and/or is there a replacement?

$query = INSERT into $table values ('0', '$year',
'$month', '$day', '$hour', '$minutes', '$seconds',
'$article_name', '$content', '$admin_name');


__
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] MySQL and apostrophes, interesting problem. 42082

2002-03-10 Thread Robert Weeks

See the manual at php.net:

addslashes()
stripslashes()

I've found it easier to just turn on magic-quotes in the php.ini file

This is all covered at php.net

Robert
- Original Message - 
From: Nick Patsaros [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Sunday, March 10, 2002 11:23 AM
Subject: [PHP-DB] MySQL and apostrophes, interesting problem. 42082


 I'm working with a simple form which submits field
 data to a MySQL database.  This is for the purpose of
 generating a dynamic news page for my site. 
 Interestingly enough I've found that any time I try to
 submit data that contains an apostrophe ' it gives
 me an error and will not send the data (any of it) to
 the database. 
 
 How can I change my database query, or escape out
 apostrophes?  I'm looking for the easiest fix out
 there of course.  Below is my current DB query. I
 realize I'm using apostrophes for my variables... is
 this acceptable syntax and/or is there a replacement?
 
 $query = INSERT into $table values ('0', '$year',
 '$month', '$day', '$hour', '$minutes', '$seconds',
 '$article_name', '$content', '$admin_name');
 
 
 __
 Do You Yahoo!?
 Try FREE Yahoo! Mail - the world's greatest free email!
 http://mail.yahoo.com/
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php