MySQL Forums
Forum List  »  PHP

Re: single quote in data breaks file load
Posted by: Steve Szmidt
Date: July 26, 2005 01:21PM

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");


Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.