MySQL Forums
Forum List  »  PHP

Re: Concat Occasionally Drops a Character or Two
Posted by: Jonathan Shaltz
Date: September 28, 2009 09:57PM

Update: the chunks are exactly 100K, as expected, in PHP before cleaning, and around 105K, varying of course, after running through the MySQLi addslashes function.

The MD5s do match for those chunks that come through at 100K, but do not match for those that lose a byte.

This confirms that data which is fine at this step:

$chunk = file_get_contents($path, FILE_BINARY, null, ($chunkNum-1) * MAX_CHUNK_SIZE, MAX_CHUNK_SIZE);

...seems to get garbled if I import it with either of these two steps:

$sql = "INSERT INTO BlobTest (Name, Data) VALUES ('$chunkNum', '" . $content[$chunkNum] . "')";
/* or */
$cleanContent = $content[$chunkNum];
$sql = "UPDATE Media SET Content = CONCAT(Content, '$cleanContent') WHERE Media = $mediaID";

...because it's wrong at this step:

logToFile("After concat, len = " . numToText(self::$db->query_scalar("SELECT LENGTH(Content) FROM Media WHERE Media = $mediaID")));

I am stumped. Unless I'm missing something, it looks like MySQL is just not processing the incoming data correctly, which doesn't make sense. If I'm doing something wrong, that's great news, because I can fix it. If this really is a database issue I don't know what I can do aside from find a new host and port my database to PostgreSQL if the problem still exists.

- Jonathan

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.