Page 1 of 1

getting all data in mysql

Posted: Mon Sep 15, 2003 4:20 am
by yaron
Hi all.
I have a script that read files content and save it on mysql db.
I have noticed that some files are not saved but I don't get any error from mysqlor php.
I turn the each file to a big string and store it as a row in the db.
I've used the function addslashes() before the storing and it solved most of the problems but still some strings are not stored.
The files are too big and I don't know which character is causing the problem (size of string is not the problem).
Any other functions besides addslashes that can help me?
Thanks....

Posted: Mon Sep 15, 2003 4:55 am
by JAM
Do you have your error reporting bumbed up to max? Are your magic_quotes_gpc set to on or off?

Code: Select all

if (!get_magic_quotes_gpc()) {
    echo 'You should use addslashes()';
} else {
    echo 'You should NOT use addslashes()';
}

Posted: Mon Sep 15, 2003 5:23 am
by yaron
If I don't use addslashes() many of the strings are not stored!
isnn't the get_magic_quotes_gpc should be on or off for all strings?

Posted: Mon Sep 15, 2003 5:42 am
by JAM
Just had some thoughts that could be the issue of your problem.
PHP Manual wrote: magic_quotes_gpc boolean
Sets the magic_quotes state for GPC (Get/Post/Cookie) operations. When magic_quotes are on, all ' (single-quote), " (double quote), \ (backslash) and NUL's are escaped with a backslash automatically.
Example:

Code: Select all

$filename "foofoo'foofoo";

// if magic_quotes_gpc = 0
echo addslashes($foo); 
// foofoo''foofoo - ok, now will work with stripslashes

// if magic_quotes_gpc = 1
echo addslashes($foo); 
// foofoo\\''foofoo - not ok, as magic_quotes allready added the \ you are adding additional \''s
Meaning, that if you then decide to use stripslashes on it, double '\'' becomes a single ''', and that could break it.