Link to home
Start Free TrialLog in
Avatar of syedasimmeesaq
syedasimmeesaqFlag for United States of America

asked on

uploads contents of csv but not excel

hello all
my code for csv works fine but when I try to upload excel, it doesn't work. How do I change it so I can upload excel files

Thanks
<?php 
 
 
require_once('connect_info.php');
// yourfile.csv must be in the same directory as this php file 
$handle = fopen ("upload8\\".$_SESSION['filename'],"r+"); 
 
while ($data = fgetcsv ($handle, 3000, ",")) { 
$atsign = "@no.mail"; 
$gtoken = mysql_real_escape_string ($data[0]);
 
$dedupe = mysql_query("select token from users where token = '".$gtoken."'") or die ("tokens not selected : " .mysql_error());
$derow = mysql_num_rows($dedupe);
if($derow == 0) { 
$query = "insert into users (token) values ('".$gtoken."')";
$result = mysql_query($query) or die("Invalid query: <BR>" . mysql_error().__LINE__ ."<BR>"."Source code ". __FILE__); 
}
 
echo "upload8\update.csv";
 
} 
 
echo "Tokens inserted"; 
//mysql_close($link); 
fclose ($handle); 
header("location: admin.php");
exit;
?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ivo Stoykov
Ivo Stoykov
Flag of Bulgaria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial