getting all data in mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
yaron
Forum Contributor
Posts: 157
Joined: Fri Aug 22, 2003 8:40 am

getting all data in mysql

Post 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....
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post 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()';
}
yaron
Forum Contributor
Posts: 157
Joined: Fri Aug 22, 2003 8:40 am

Post 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?
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post 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.
Post Reply