Hi,
I was trying to import the excel values in mysql DB. While trying, am facing this error. Please help me out:
Fatal error: Call to undefined function mysql_real_espace_string() in E:\xampp\htdocs\read.php on line 49
CODING:
<?php
ini_set('memory_limit', '16M');
set_time_limit(0);
require_once("E:/xampp/htdocs/phpexcel/Classes/PHPExcel.php");
$inputFileName='./xls/test_data.xls';
/** Identify the type of $inputFileName **/
$inputFileType=PHPExcel_IOFactory::identify($inputFileName);
/** Create a new reader of the type that has been identified **/
$objReader=PHPExcel_IOFactory::createReader($inputFileType);
/**Load $inputFileName to a PHPExcel object **/
$objPHPExcel=$objReader->load($inputFileName);
/**Get the calculated value from a cell**/
$worksheet='Worksheet';
#$cell='A1';
/**Get a normal value from a cell **/
#$cellValue=$objPHPExcel->getSheetByName($worksheet)->getCell($cell)->getCalculatedValue();
$worksheet=$objPHPExcel->getActiveSheet();
$highestRow = $worksheet->getHighestRow();
$highestColumn = $worksheet->getHighestColumn();
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
$myServer = "local";
$myUser = "zzzz";
$myPass = "yyyy";
$myDB = "xxxx";
//connection to the database
$dbhandle = mysql_connect($myServer, $myUser, $myPass) or die("Couldn't connect to SQL Server on $myServer");
//select a database to work with
$selected = mysql_select_db($myDB, $dbhandle) or die("Couldn't open database $myDB");
$row = array();
for ($row = 1; $row <= $highestRow; ++$row)
{
for ($col = 0; $col <= $highestColumnIndex; ++$col)
{
$row[$col] = mysql_real_espace_string($worksheet->getCellByColumnAndRow($col, $row)->getValue());
}
mysql_query("INSERT INTO test (name,hours) VALUES ($row[1],$row[2])") or die("can't insert");
}
?>
Thanks....