Re: single quote in data breaks file load
Roland Bouman wrote:
> I mean, your snippet suggests you're inserting
> data youself using some kind of INSERT
> INTO...VALUES syntax. Is that the case, or are you
Sorry, doing mutiple things, yes you are right here's the code.
It's not a syntax error on the command, but when a record contain a single quote, it breaks the load, with the message in the first post.
while ( ( $data = fgetcsv($Handle, 384) ) !== FALSE) {
list($AccCode, $Src, $Dest, $DestContext, $CLID, $Channel, $DstChannel,
$LastApp, $LastData, $Start, $Answer, $Stop, $Duration,
$BillSec, $Outcome, $AmaFlags) = $data;
$query = "insert into cdrcleanup (AccCode, Src, Dest, DestContext, Channel, CLID, DstChannel,
LastApp, LastData, Start, Answer, Stop, Duration, BillSec, Outcome, AmaFlags, UserDef, Rate, Periods, Amount, CustID)
values('$AccCode', '$Src', '$Dest', '$DestContext', '$CLID', '$Channel', '$DstChannel',
'$LastApp', '$LastData', '$Start', '$Answer', '$Stop', '$Duration', '$BillSec',
'$Outcome', '$AmaFlags', '$UserDef', '$Rate', '$Periods', '$Amount', '$CustID')";
if(!($result2 = mysql_query($query, $link))) {
print("Invalid query: " . mysql_error()."\n");
print("SQL: $sql\n");
die();
}
$rows++;
}