mysql->quote problem with IMP and Turba

Jeff Tucker jefft@wciatl.com
Tue, 09 Oct 2001 18:17:57 -0400


Hi,

I'm working on a problem I thought I had solved. For starters, I'm using 
Horde, IMP, and Turba all updated from CVS two nights ago. I also updated 
PHP, including PEAR from CVS at the same time. I would expect everything to 
be pretty much cutting-edge.

What I found was that IMP was not generating valid MySQL requests. 
Specifically, the strings were not being quoted correctly. Strings weren't 
getting any quotes at all. In my log, I get entries like:

26278 Query       insert into horde_prefs (pref_uid, pref_scope, pref_name, 
pref_value) values(jeff@cesmail.net, imp, last_login, 1002665324)

Clearly, the email address, among other things, should have quotes around 
it.

OK, I fixed this problem by modifying PEAR, the DB/mysql.php file. In that 
file, I changed the line:
return "'".mysql_escape_string($str)."'";

To be
return "''".mysql_escape_string($str)."''";

Note the double quotes. This fixed the problem and SQL requests were 
properly quoted. IMP has worked flawlessly, including DB functions like 
preferences, identities, etc.

Today, I tried to get Turba working with IMP. The problem is that all SQL 
queries are double-quoted. So, I get things like:

26275 Query       INSERT INTO turba_objects (object_name, object_email, 
object_title, object_company, object_homePhone, object_workPhone, 
object_cellPhone, object_fax, object_homeAddress, object_workAddress, 
object_notes, owner_id, object_id) VALUES (''Ellen'', 
''ellen@test-domain.org'', '''', '''', '''', '''', '''', '''', '''', '''', 
'''', ''jeff@cesmail.net'', ''3d35a167141a8db53ffa4e5ca4125226'')

Now, everything is double-quoted! Arrgh!

Anyway, does anyone know the secret recipe to get IMP, Turba, and MySQL all 
playing together at the same time? BTW, if I set the quote function back 
the way it was originally, Turba works fine, but IMP can no longer use the 
DB.

Thanks very much,
Jeff

-- 
Jeff Tucker
Williams Consulting, Inc.
jefft@wciatl.com