Click here to get back home

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

 HomeNewsGroups | Search

comp.lang.php - PHP programming language discussions 

get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
uploading special characters from excel to mysql and php binary/Image matech 06-17-2008
Posted by matech on June 17, 2008, 10:47 am
Please log in for more thread options
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 =99 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] =3D=3D ''){
$strSQLQuery .=3D "'',";
} else {
$strSQLQuery .=3D
"'".htmlentities(addslashes($SelectedFieldValues[$TempSelect]))."',";
}
}

or

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

or

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

or

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


Posted by Captain Paralytic on June 17, 2008, 11:00 am
Please log in for more thread options
I have read and re-read this post and I cannot manage to make it make
any sense.

show/hide quoted text
mysql is an RDBMS. You do not upload special characters to it. You
insert values into fields.

show/hide quoted text
What do you mean by this? If I have a VARCHAR field, it can only hold
text. I will not see an image there.

show/hide quoted text
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.

Posted by matech on June 17, 2008, 11:26 am
Please log in for more thread options
The following is the function used to upload the excel file.

function UploadProductTemp($arrayDetails) {
global $configTables;
extract($arryDetails);
show/hide quoted text
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;
show/hide quoted text
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();
show/hide quoted text
{
show/hide quoted text
foreach ($SelectFields as $TempSelect) {
$sel = 's'.$TempSelect;
$Selected = $$sel;
if($j==$Selected){
show/hide quoted text
['cells'][$i][$j];
}
}
}
show/hide quoted text
$SelectedFieldValues['catalogNumber'])){
         $strSQLQuery = "update bioscience_product set ";
         foreach ($SelectFields as $TempSelect) {
         $strSQLQuery .=
$TempSelect."='".htmlentities(addslashes($SelectedFieldValues[$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($SelectedFieldValues[$TempSelect]))."',";
         }
         }
         $strSQLQuery = rtrim($strSQLQuery,",");
         $strSQLQuery .= ")";
show/hide quoted text
         }
}
}
}
}
}
}

Similar ThreadsPosted
PHP/Mysql/special characters problem October 26, 2004, 12:29 am
Replace special characters by non-special characters November 5, 2004, 11:08 pm
How to convert HTML special characters to the real characters with a Java script March 21, 2006, 1:26 pm
Special characters. August 28, 2007, 9:24 am
Special Characters? March 25, 2009, 6:21 am
Getting rid of special characters December 21, 2009, 12:55 pm
Special characters (זרו) and zipfiles January 6, 2005, 11:18 am
php handling special characters? July 13, 2005, 10:01 pm
Retrieving special characters March 28, 2006, 10:55 pm
Special Characters into database January 28, 2008, 5:58 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Driving a better car - Fuelzilla.com

Cabling site for homeowners and pros alike - Cabling-Design.com

Friends:

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap
Privacy Policy