php - The apostrophe and quotation mark
I eventually figured out why user data wasn't
appearing in the database when sent with my php form.
I added
"or die(mysql_errno() . ": " .
mysql_error(). "\n");" to every database call in
the script to find out why on earth user data was not appearing when they would
submit results. I received word back after adding those lines that there was a
syntax error and that the user had to remove the brackets and apostrophes from
the text in order to get the data to submit properly. In order to properly
process the symbols, you need to activate magic_quotes_gpc, which process
apostrophes, quotation marks and other string related symbols for GET, POST, and
COOKIE processes.
I modified the
php.ini file located at /usr/local/php/lib and restarted apache but still no
luck.
I tried the following line of
code from the php.net site and it didn't work for
me:
<?
ini_set
("magic_quotes_gpc"
,"1"
);
?>
I then checked the phpinfo() on
the server and found that the search path for the php.ini file is actually
/usr/lib/php.ini. Apparently there are two versions living on the server. I
opened a Terminal window and typed
in:
cd
/usr/lib
sudo pico
php.ini
I then modified the
get_magic_quotes_gpc to "On" and saved the file and then
typed:
sudo apachectl
graceful
to gracefully restart the Apache
server.
Rerunning the phpinfo() showed
that get_magic_quotes was now active. I re-tested the form and it now functions
as intended.
Posted: Wed - October 15, 2003 at 11:45 AM