472,328 Members | 1,051 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 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 3461
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...
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; ")…. ...
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...
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...
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...
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...
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...
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...
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...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

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.