[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

how to use two buttons with php
hi i have one form. there are three fields which are to be filled by the user. and then there are tw

New to Arrays
Hi I am new to PHP (a week and a half now) and I am just beginning to read about arrays. I understan

frames get header location..
i have two frames, one top, one bottom. how do i do a form on the bottom frame that gives me the ur

Is it a good practice to store user info. in sessions?
I am making a user class for my script which stores all the user information in sessions. It takes u

Warning message
I've put a website that I was doing live and I'm getting this warning message when I try to add a ne

Get word number x from string?
How can I use a function to loop through a string, and "have a look at" every word in the

help with mysql_error()
Hi,

I am trying to insert data into a table, but I am not able to insert it. I wanted to see

I am stumped
OK. Here is what I am trying to do. I have the conditions set, and if the conditions are met, I want

what business processes?
Hi,

A general question. What business processes (like OTC - Order to Cach, P2P, R2R etc)

login form can you find my error?
registrationform.php seems fine send data to registration.php
registration.php seems fine checks

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