Welcome Guest, Not a member yet? Register   Sign In
Database Error
#1

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]
Reply
#2

Image files are binary ... not UTF-16 text.
Reply
#3

(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?
Reply
#4

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB