By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,287 Members | 1,544 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,287 IT Pros & Developers. It's quick & easy.

MySQL-fgets Apostrophe Problem

P: n/a
I have a PHP script where I extract data from a file and insert it into
a MySQL database.

Every time I run the PHP script I receive an SQL error that states:
"You have an error in your SQL syntax. Check the manual that
corresponds to your MySQL server version for the right syntax to use
near" ... and then it quotes a line from the file (where I'm trying to
extract the data from) starting with an apostrophe.

As an example, if the file (that I'm trying to extract data from) has
ONLY the following line:
"Hello, I don't know what's going on??"

The full error returned by SQL will be...
"You have an error in your SQL syntax. Check the manual that
corresponds to your MySQL server version for the right syntax to use
near 't know what's going on??"

I use the fgets function to extract the data from the file - if this
helps in determining the problem.

Can anyone offer any help as to why I'm receiving this error? I've been
Googling away but can't seem to find any logical answer.

Thanks,

Ryan

Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Found the answer after the first search on Yahoo!!

All I had to do was use the addslashes() php function.
Ryan

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.