CodeIgniter Forums
Database Error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19)
+--- Thread: Database Error (/showthread.php?tid=64928)



Database Error - jnymris - 04-12-2016

Hi,

I'm looking to upload an Image and store the image (not the file path) in the database.

I'm able to upload the image okay and can see it is going to the temp directory. I'm then using file_get_contents however when attempting to insert this into a SQL Server i'm getting the following error message:
"Error Number: IMSSP/-46

An error occurred translating the query string to UTF-16: No mapping for the Unicode character exists in the target multi-byte code page. .
(Bunch of text including characters such as ����/�ExifMM* � ���"

I've had a look around but cannot see to get the bottom of this error. Here is my code.

[CODEBOX]
echo '<form method="post" action="'.BASE_URL().'car/upload_service" enctype="multipart/form-data">';
echo 'CarID <input type="text" name="car_id" value="'.$car->id.'" />';
echo 'Upload File <input type="file" name="file" />';
echo '<input type="submit" value="upload" />';
echo '</form>';
[/CODEBOX]

[CODEBOX]
$this->db->query("INSERT INTO car_history ('car_id','serviced_date','data2') VALUES($car_id,'".DATE('Y.m.d')."',N'".$file."')");
[/CODEBOX]


RE: Database Error - Narf - 04-12-2016

Image files are binary ... not UTF-16 text.


RE: Database Error - jnymris - 04-12-2016

(04-12-2016, 10:57 AM)Narf Wrote: Image files are binary ... not UTF-16 text.

So how do I insert this? 

I have two colums inside MSSQL which I have tried
One is set to Image and the other is set to varbinary(MAX) Both fail with the same error?


RE: Database Error - InsiteFX - 04-12-2016

Images should not be stored inside a database even MS states this, store the image file name and path in the database and the image in the file system.