473,549 Members | 2,948 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

uploading special characters from excel to mysql and php binary/Image

I have a problem with uploading special characters from excel files to
mysql 5. It doesn't matter if I use UTF-8 or iso-8859-1 when uploading
the trademark ™ symbol. htmlspecialchar s() or htmletities() doesn't
help? the database doesn't show the data in the field but replaces it
with the binary/Image information.

the following are examples of how I've tried loading the data along
with UTF-8 or iso-8859-1:
foreach ($SelectFields as $TempSelect) {
if($SelectedFie ldValues[$TempSelect] == ''){
$strSQLQuery .= "'',";
} else {
$strSQLQuery .=
"'".htmlentitie s(addslashes($S electedFieldVal ues[$TempSelect]))."',";
}
}

or

foreach ($SelectFields as $TempSelect) {
if($SelectedFie ldValues[$TempSelect] == ''){
$strSQLQuery .= "'',";
} else {
$strSQLQuery .=
"'".htmlentitie s($SelectedFiel dValues[$TempSelect])."',";
}
}

or

foreach ($SelectFields as $TempSelect) {
if($SelectedFie ldValues[$TempSelect] == ''){
$strSQLQuery .= "'',";
} else {
$strSQLQuery .=
"'".htmlspecial chars(addslashe s($SelectedFiel dValues[$TempSelect]))."',";
}
}

or

foreach ($SelectFields as $TempSelect) {
if($SelectedFie ldValues[$TempSelect] == ''){
$strSQLQuery .= "'',";
} else {
$strSQLQuery .=
"'".htmlspecial chars($Selected FieldValues[$TempSelect])."',";
}
}

Jun 27 '08 #1
2 3565
On 17 Jun, 15:47, matech <robert.mat...@ hotmail.co.ukwr ote:
I have read and re-read this post and I cannot manage to make it make
any sense.
I have a problem with uploading special characters from excel files to
mysql 5.
mysql is an RDBMS. You do not upload special characters to it. You
insert values into fields.
It doesn't matter if I use UTF-8 or iso-8859-1 when uploading
the trademark ™ symbol. htmlspecialchar s() or htmletities() doesn't
help? the database doesn't show the data in the field but replaces it
with the binary/Image information.
What do you mean by this? If I have a VARCHAR field, it can only hold
text. I will not see an image there.
the following are examples of how I've tried loading the data along
with UTF-8 or iso-8859-1:

foreach ($SelectFields as $TempSelect) {
* *if($SelectedFi eldValues[$TempSelect] == ''){
* * * $strSQLQuery .= "'',";
* *} else {
* * *$strSQLQuery .=
"'".htmlentitie s(addslashes($S electedFieldVal ues[$TempSelect]))."',";
* *}

}
Please show us where $SelectFields comes from, what data gets into
$TempSelect, what the table schema is, which field of the table
$TempSelect will be loaded into, what the value is that is found in
the field.

In other words, give us something concrete to work with.
Jun 27 '08 #2
The following is the function used to upload the excel file.

function UploadProductTe mp($arrayDetail s) {
global $configTables;
extract($arryDe tails);
$ArrayFieldName = $this->GetFieldName(' product_temp');
foreach($ArrayF ieldName as $key=>$values){
if($values['Field'] != 'productID') $SelectFields[$values['Field']]
= $values['Field'];
}
function GetExcelExtensi on($file){
$revfile=strrev ($file); // Reverse the string for getting the
extension
$arr_t=explode( ".",$revfil e);
$file_type=$arr _t[0];
return strrev($file_ty pe); // File Extension
}
$file_type=GetE xcelExtension($ FilePath);
if($file_type== 'xls' || $file_type=='XL S') $supported=1;
else $supported=2;
if($supported>1 ){
echo "Sorry, File can't be uploaded, Please Upload only excel
file."; exit;
}else{
$Destination = $FilePath;
$Destination = 'upload/product.xls';
$obj=new product();
$objSupp=new supplier();
$data=new Spreadsheet_Exc el_Reader();
$data->read($Destinat ion);
for ($i = $startFrom+1; $i <= $data->sheets[0]['numRows']; $i++)
{
for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {
foreach ($SelectFields as $TempSelect) {
$sel = 's'.$TempSelect ;
$Selected = $$sel;
if($j==$Selecte d){
$SelectedFieldV alues[$TempSelect] =$data->sheets[0]
['cells'][$i][$j];
}
}
}
if(count($Selec tedFieldValues) 0 && $i>$startFrom){
if($obj->isProductExist s('product_temp ',
$SelectedFieldV alues['catalogNumber'])){
$strSQLQuery = "update bioscience_prod uct set ";
foreach ($SelectFields as $TempSelect) {
$strSQLQuery .=
$TempSelect."=' ".htmlentities( addslashes($Sel ectedFieldValue s[$TempSelect]))."',";
}
$strSQLQuery = rtrim($strSQLQu ery,",");
$strSQLQuery .= "where catalogNumber=' ".
$SelectedFieldV alues['catalogNumber']."'";
}else{
if(($SelectedFi eldValues['productName']!='') and
($SelectedField Values['catalogNumber']!='')) {
$strSQLQuery = "insert into product_temp(";
$strSQLQuery .= implode(",",$Se lectFields);
$strSQLQuery .= ")values(";

foreach ($SelectFields as $TempSelect) {
if($SelectedFie ldValues[$TempSelect] == ''){
$strSQLQuery .= "'',";
}else{
$strSQLQuery .=
"'".htmlentitie s(addslashes($S electedFieldVal ues[$TempSelect]))."',";
}
}
$strSQLQuery = rtrim($strSQLQu ery,",");
$strSQLQuery .= ")";
$this->query($strSQLQ uery, 0);
}
}
}
}
}
}
}
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
4457
by: Ralph Freshour | last post by:
I'm trying to code the ability for my users to upload up to photo's to mysql database - can someone point me in the right direction as to how this might be done in php? Perhaps a tutorial or some code samples? My two php books don't cover uploading photo's to a web site. Thanks...
5
10430
by: Matthew Shaw | last post by:
We have a web-based reporting application written in J2EE that writes out to excel using response.setContentType ("application/vnd.ms-excel; ")…. The problem is that where we have any special characters in our report result set E.g umlauts and accents ( ASCII values 128 to 165 ) this data is corrupted, and does not appear correctly. The...
11
3232
by: bissatch | last post by:
Hi, I am trying to upload an image, create a new file based on that image and then store the base64 encoded image data in a database. I dont really know where my code is going wrong so I will just display it below: The following code contains the script to process the uploaded file, the form to upload the file and then a few links to...
4
5248
by: Ewok | last post by:
let me just say. it's not by choice but im dealing with a .net web app (top down approach with VB and a MySQL database) sigh..... Anyhow, I've just about got all the kinks worked out but I am having trouble preserving data as it gets entered into the database. Primarily, quotes and special characters. Spcifically, I noticed it stripped...
10
7380
by: John Smith | last post by:
I know that uploading an image to a database has been covered, oh, about 3 trillion times. However, I haven't found anything covering uploading to a MySQL database with .net. Please don't recommend storing the image to the filesystem and only keeping a pointer to that in the table. I want to dump the image to a table. My code dumps the...
6
7545
by: chiya | last post by:
plz anybody help me in uploading data from excel file to mysql database. data in excel sheet is in vertical format not horizontally. I mean to say that the columns of mysql tables are in rows in excel.
221
367123
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application needs to store entire files, the preferred method is to save the file onto the server’s file-system, and store the physical location of the file in...
3
2038
by: jatin299 | last post by:
hi ..problem in uploading image..using servlet to upload image in mysql..use html form so user given the path of image..but giving error.here is the code..help me on this. import java.sql.*; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class LoadImage extends HttpServlet{
2
2317
by: =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?= | last post by:
jodleren escribió: I haven't found the PHP manual page where such feature is documented but a few tests have shown that this behaviour changes depending on the charset parameter of the "Content-Type" HTTP header; even if I don't set an actual HTTP header and I just use a <metatag: <meta http-equiv="Content-Type" content="text/html;...
0
7520
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7956
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7470
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5368
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1936
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1058
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.