I am trying to insert email headers read from impap in to a mysql text field. Problem is the headers are full of slashes, commas, quotes, line feeds. mysql_escape doesnt come near it. The different mail server responses can lead to quite different headers. Do i have to do some weird voodoo before storage?
            Asked
            
        
        
            Active
            
        
            Viewed 270 times
        
    2 Answers
1
            mysql_real_escape_string() should really be all you need:
mysql_real_escape_string() calls MySQL's library function mysql_real_escape_string, which prepends backslashes to the following characters: \x00, \n, \r, \, ', " and \x1a.
are you working with multiple connections? If you are, be sure to add $link_identifier to the call, as defined in the manual.
 
    
    
        Pekka
        
- 442,112
- 142
- 972
- 1,088
- 
                    I am a pillock - mysqlescape string does work just fine. Late nights and commas got me fuzzcooed. – Feb 06 '10 at 00:27
0
            
            
        Use prepared statements instead of building the query using strings.
See for example here.
 
    
    
        Community
        
- 1
- 1
 
    
    
        Mark Byers
        
- 811,555
- 193
- 1,581
- 1,452