[function.file]: failed to open stream: No such file or directory


Posted on 16th Feb 2014 07:03 pm by admin

Okay I wrote this little script to upload a csv file that is located on my webhosts server to a mysql database. Something is wrong because I am getting the following error:

Warning: file(./html/beer/uploads/filename.csv) [function.file]: failed to open stream: No such file or directory in /home/content/d/l/a/dlanden/html/beer/uploads/upload_csv_mysql.php on line 12
insert into sunocoimport values ('')
Column count doesn't match value count at row 1

I did a syntax check and everything checked out. Here is the code:

$fcontents = file ('./html/beer/uploads/filename.csv');
# expects the csv file to be in the same dir as this script

for($i=0; $i<sizeof($fcontents); $i++) {
$line = trim($fcontents[$i]);
$arr = explode(",", $line);
#if your data is comma separated
# instead of tab separated,
# change the 't' above to ','

$sql = "insert into sunocoimport values ('".
implode("','", $arr) ."')";
mysql_query($sql);
echo $sql ."
n";
if(mysql_error()) {
echo mysql_error() ."
n";
}
}
?>

I am a newbie so any advice would be appreciated!

No comments posted yet

Your Answer:

Login to answer
205 Like 46 Dislike
Previous forums Next forums
Other forums

unexpected T_STRING
error log "[Sat Jan 09 18:27:58 2010] [error] [client 127.0.0.1] PHP Parse error: syntax error

All possible combinations of String in PL/SQL
Hi All,

Could you please explain the logic of getting all possible combinations of String

PHP & Java
Hello,

can PHP code be used inside java code?

Code: <SCRIPT LANGUAGE="Java

Socket programming
Hello all,

I have a PHP socket script. GPS trackers connect to this socket. IMEI verification

PHP code for a proxy
I was wondering which function I could use to create an online proxy tool. I was thinking cURL would

login page does not execute a else statement
I've created a login page using sessions.
When an incorrect user name or password is entered then

get multiple rows
Hi I want to get multiple rows from a db

I am using this for the db query
Code: public

Tree Menu
Hi guys,

Can anyone help me making a tree navigation system? I have a site where I'm allowin

Logic question
im wondering what's the best method to do the above list:

it is for alliance @ MMORPG game

Multiple Options for a Single Page
For this example I want to use the Handlers option which is under Fed Admin and all the related codi

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash