[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

Collecting AOL Search Terms
I am attempting to collect AOL search terms. I know the code is correct (it works for google, bing,

Fetching META TAGS through
Hello everybody
I want to fetch meta tags of a domain.
It will be done from following code of

SQL Query/echo not working
Hey all,

I'm trying to run (what I thought) was a simple operation and it isn't working. I h

How could I combine these arrays??
Hello.. I'm trying to figure out a way to combine these first two arrays to get the last array..

Need help: how to catch acess of undefined class properties
Hello. I am learning OO with PHP and have hit a problem.
Some code runs as perfectly valid code,

Read from a text file after a specific word
Hi all.

I have a text file that looks like the one below.
I know how to open the text fi

reating a background image
I am building a site in drupal and have a php form in it, due to certain annoyances with module buil

making web pages for accounts
Hello, I would like to make pages for accounts on my website im making (its not a real website..im j

please fix the error
What is the error in the below code ???
Line number On/Off | Expand/Contract <?php

Need help with an email blocker for a guessbook
I am new with php and here is a simple guessbook page but I am being hit with spam from a group of t

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