Re: getcsv error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Brian Hazelton wrote:
I have a script which uploads csv data into a database. This works well and has worked in every instance so far. However what I am noticing is that today, even if I escape the data before putting it into mysql it will not enter a line if it has a single quote, once I take out the single quote it enters it into the database so I know it is the single quote, is this an error or are single quotes not allowed in csv...?


I figured out part of the problem. The problem lies with one of my functions for cleaning the data before putting it into the database. I have a function, see below, that will clean the data to put into mysql and work whether magic quotes is on or off. It is not working because I echo the query and the part I need escaped is not being escaped. I try mysql_real_escape_string and it is being escaped by that so I think the problem is something with my function, if anyone can help that would be appreciated.

function clean($str){
   if(get_magic_quotes_gpc()){
       stripslashes($str);
       mysql_real_escape_string($str);
       return $str;
   }
   else{
       mysql_real_escape_string($str);
       return $str;
   }
}



$name = 'O'Leksy';
$cleaned_name = clean($name);

echo of $cleaned name = O'Leksy';
if mysql_real_escape_string is used it echoes O\'Leksy';


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux