473,397 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Upload image to Mysql with PHP fails

Hi..

I am really bashing my head on this one. I have an image I have manipulated, now I want to push it back to the database.

So, to accomplish this, I have the following:

--- $image_file = fopen ('/var/tmp/tmp.jpg','rb');
$image_data = fread ($image_file, filesize ('/var/tmp/tmp.jpg'));
$image_data = addslashes ($image_data);
fclose ($image_file);


$sql = "UPDATE article_attachment SET content = $image_data where id = $article_data[0]";

$image_update = mysql_query ($sql);

echo mysql_error($dbi);
---
It's more drawn out than it should be, but I am breaking everything down to try and solve this. I get the error:

"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '▒▒▒▒\0JFIF\0\0\0\0\0\0▒▒\0>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), defa' at line 11"

I see some high order characters that don't appear to be getting escaped properly, should this be happening?...

Thanks,
Richard.
Aug 5 '14 #1
1 1155
Found the issue. In my sleep deprived state, I had reused the $image_data variable. It was already an array, and I was re-casting image data into it. Made for some confusion.
Aug 6 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: William Drew | last post by:
REQUEST FOR DISCUSSION (RFD) unmoderated group comp.databases.mysql This is an invitation to discuss the following proposal to create newsgroup comp.databases.mysql. Please note that YOU...
3
by: Kevin | last post by:
hi I want to create an upload image page. how do I do that?
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
4
by: joe | last post by:
how to resize an upload image and then change to binary & insert to db
4
by: meseenu | last post by:
Hi every one, iam developing an application where i want to upload image and video files in to a oracle data base. I have used BLOB data type to store the image and video files. iam using...
0
by: aris1234 | last post by:
hello.. How to upload image file in page update ..?? i have logic like this : if user upload new image then old image must delete and update DB used new name if user not upload new image then...
7
by: xx75vulcan | last post by:
Hi, I've got a PHP Upload Form that works great, unless that is, the image your uploading has been modified through a photo editing software. Example: if I upload the image straight from a...
5
by: rahia307 | last post by:
hi i want to upload image with epoch date Concatenate. image is load successfully. but when i does not want to image upload then epoch date is store in database i use this code if...
5
by: rahia307 | last post by:
Hi I am using this code for upload image. <table> <form action="process.php method="POST" enctype="multipart/form-data"> <tr> <td align="right">Image1 :</td> <td><input type="file"...
3
by: premprakashbhati | last post by:
hi, good evening.. i am going to upload an image in a web form .....for that iam using HTML input(file) control and one web control button i.e., Upload_Button() here is the code ...its work fine...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.