sandhya Posted December 11, 2008 Share Posted December 11, 2008 Hi all, please give me a solution for this. I have converted an Excel file into .csv file. And browsed from the form with the form field named 'csvfile'. And i'm trying to upload the form using the following code. $file1=$_FILES['csvfile']['name']; $lines = file($file1); foreach ($lines as $line) { $cols = explode(';', $line); mysql_query("INSERT INTO aop_class (catid, orgname, address, city, country, phone, description) VALUES(".trim($cols[0]).",'".trim($cols[1])."','".trim($cols[2])."','".trim($cols[3])."','".trim($cols[4])."','".trim($cols[5])."','".trim($cols[6])."')") or die(mysql_error()); But, after execution i'm getting the following wornings Warning: file(): Unable to access class1.csv in /home/sphoor21/public_html/mitrahelp/admin/classified.php on line 165 Warning: file(class1.csv): failed to open stream: Permission denied in /home/sphoor21/public_html/mitrahelp/admin/classified.php on line 165 So, Please tell me what is happening her. How can I upload a csv file to the database. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/136466-solved-problem-with-uploading-csv-file-to-the-mysql-database/ Share on other sites More sharing options...
Mchl Posted December 11, 2008 Share Posted December 11, 2008 DO you have acess to phpMyAdmin? It will give you an easy way to import your CSV data. Quote Link to comment https://forums.phpfreaks.com/topic/136466-solved-problem-with-uploading-csv-file-to-the-mysql-database/#findComment-712294 Share on other sites More sharing options...
sandhya Posted December 11, 2008 Author Share Posted December 11, 2008 Yes i"ve the access to PhpMyAdmin. But I am developing the admin tool for the clients. Through that they can easily upload the data to the database. what is the error in that code? Quote Link to comment https://forums.phpfreaks.com/topic/136466-solved-problem-with-uploading-csv-file-to-the-mysql-database/#findComment-712299 Share on other sites More sharing options...
Mchl Posted December 11, 2008 Share Posted December 11, 2008 Consider giving them limited access to phpMyAdmin then... It uses LOAD DATA INFILE method, so it is much faster, than INSERTing row by row. If you want to stick with your own script, perhaps you should also consider uploading csv first, and then using LOAD DATA INFILE. Quote Link to comment https://forums.phpfreaks.com/topic/136466-solved-problem-with-uploading-csv-file-to-the-mysql-database/#findComment-712302 Share on other sites More sharing options...
sandhya Posted December 11, 2008 Author Share Posted December 11, 2008 Basically it's not possible to give them the access to php MyAdmin in this case. So, Please give me a solution. Quote Link to comment https://forums.phpfreaks.com/topic/136466-solved-problem-with-uploading-csv-file-to-the-mysql-database/#findComment-712303 Share on other sites More sharing options...
Mark Baker Posted December 11, 2008 Share Posted December 11, 2008 Basically it's not possible to give them the access to php MyAdmin in this case. So, Please give me a solution. Michl has offered you a solution If you want to stick with your own script, perhaps you should also consider uploading csv first, and then using LOAD DATA INFILE. Quote Link to comment https://forums.phpfreaks.com/topic/136466-solved-problem-with-uploading-csv-file-to-the-mysql-database/#findComment-712313 Share on other sites More sharing options...
sandhya Posted December 11, 2008 Author Share Posted December 11, 2008 Thank you very much. code worked properly after uploading the csv file to the server. thank u very much. Quote Link to comment https://forums.phpfreaks.com/topic/136466-solved-problem-with-uploading-csv-file-to-the-mysql-database/#findComment-712322 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.