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


ini_set('memory_limit', '16M');


/** Identify the type of  $inputFileName **/

/** Create a new reader of the type that has been identified **/

/**Load $inputFileName to a PHPExcel object **/

/**Get the calculated value from a cell**/

/**Get a normal value from a cell **/


$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");



Recommended Answers

All 5 Replies

because you have a typo in the function and the correct one is

<?php mysql_real_escape_sting()?>


can't understand. Please could me explain it briefly.

lol not mysql_real_escape_sting, but mysql_real_escape_string
those damn typos hahaha

that was very funny :D
as 54uydf said in replace line 49 in ur script with this line

$row[$col] = mysql_real_escape_string($worksheet->getCellByColumnAndRow($col, $row)->getValue());

thanks sp much guys.....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.