|
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
> 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.
show/hide quoted text
> 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.
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
> the following are examples of how I've tried loading the data along
> with UTF-8 or iso-8859-1:
> foreach ($SelectFields as $TempSelect) {
> =A0 =A0if($SelectedFieldValues[$TempSelect] =3D=3D ''){
> =A0 =A0 =A0 $strSQLQuery .=3D "'',";
> =A0 =A0} else {
> =A0 =A0 =A0$strSQLQuery .=3D
> "'".htmlentities(addslashes($SelectedFieldValues[$TempSelect]))."',";
> =A0 =A0}
> }
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
$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;
show/hide quoted text
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();
show/hide quoted text
$data->read($Destination);
for ($i = $startFrom+1; $i <= $data->sheets[0]['numRows']; $i++)
{
show/hide quoted text
for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {
foreach ($SelectFields as $TempSelect) {
$sel = 's'.$TempSelect;
$Selected = $$sel;
if($j==$Selected){
show/hide quoted text
$SelectedFieldValues[$TempSelect] =$data->sheets[0]
['cells'][$i][$j];
}
}
}
show/hide quoted text
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($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
$this->query($strSQLQuery, 0);
}
}
}
}
}
}
}
|
| Similar Threads | Posted | | 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 |
|
> mysql 5.