473,385 Members | 1,898 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,385 software developers and data experts.

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. htmlspecialchars() 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($SelectedFieldValues[$TempSelect] == ''){
$strSQLQuery .= "'',";
} else {
$strSQLQuery .=
"'".htmlentities(addslashes($SelectedFieldValu es[$TempSelect]))."',";
}
}

or

foreach ($SelectFields as $TempSelect) {
if($SelectedFieldValues[$TempSelect] == ''){
$strSQLQuery .= "'',";
} else {
$strSQLQuery .=
"'".htmlentities($SelectedFieldValues[$TempSelect])."',";
}
}

or

foreach ($SelectFields as $TempSelect) {
if($SelectedFieldValues[$TempSelect] == ''){
$strSQLQuery .= "'',";
} else {
$strSQLQuery .=
"'".htmlspecialchars(addslashes($SelectedFieldValu es[$TempSelect]))."',";
}
}

or

foreach ($SelectFields as $TempSelect) {
if($SelectedFieldValues[$TempSelect] == ''){
$strSQLQuery .= "'',";
} else {
$strSQLQuery .=
"'".htmlspecialchars($SelectedFieldValues[$TempSelect])."',";
}
}

Jun 27 '08 #1
2 3555
On 17 Jun, 15:47, matech <robert.mat...@hotmail.co.ukwrote:
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. htmlspecialchars() 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($SelectedFieldValues[$TempSelect] == ''){
* * * $strSQLQuery .= "'',";
* *} else {
* * *$strSQLQuery .=
"'".htmlentities(addslashes($SelectedFieldValu es[$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 UploadProductTemp($arrayDetails) {
global $configTables;
extract($arryDetails);
$ArrayFieldName = $this->GetFieldName('product_temp');
foreach($ArrayFieldName as $key=>$values){
if($values['Field'] != 'productID') $SelectFields[$values['Field']]
= $values['Field'];
}
function GetExcelExtension($file){
$revfile=strrev($file); // Reverse the string for getting the
extension
$arr_t=explode(".",$revfile);
$file_type=$arr_t[0];
return strrev($file_type); // File Extension
}
$file_type=GetExcelExtension($FilePath);
if($file_type=='xls' || $file_type=='XLS') $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_Excel_Reader();
$data->read($Destination);
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==$Selected){
$SelectedFieldValues[$TempSelect] =$data->sheets[0]
['cells'][$i][$j];
}
}
}
if(count($SelectedFieldValues) 0 && $i>$startFrom){
if($obj->isProductExists('product_temp',
$SelectedFieldValues['catalogNumber'])){
$strSQLQuery = "update bioscience_product set ";
foreach ($SelectFields as $TempSelect) {
$strSQLQuery .=
$TempSelect."='".htmlentities(addslashes($Selected FieldValues[$TempSelect]))."',";
}
$strSQLQuery = rtrim($strSQLQuery,",");
$strSQLQuery .= "where catalogNumber='".
$SelectedFieldValues['catalogNumber']."'";
}else{
if(($SelectedFieldValues['productName']!='') and
($SelectedFieldValues['catalogNumber']!='')) {
$strSQLQuery = "insert into product_temp(";
$strSQLQuery .= implode(",",$SelectFields);
$strSQLQuery .= ")values(";

foreach ($SelectFields as $TempSelect) {
if($SelectedFieldValues[$TempSelect] == ''){
$strSQLQuery .= "'',";
}else{
$strSQLQuery .=
"'".htmlentities(addslashes($SelectedFieldValu es[$TempSelect]))."',";
}
}
$strSQLQuery = rtrim($strSQLQuery,",");
$strSQLQuery .= ")";
$this->query($strSQLQuery, 0);
}
}
}
}
}
}
}
Jun 27 '08 #3

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

Similar topics

6
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...
5
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...
11
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...
4
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...
10
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...
6
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...
221
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...
3
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.*;...
2
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.