[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

PHP mail() with images
I'm trying to get images to send along with my HTML e-mail sent through PHP mail(). I only tried vie

login from external site
Hi my new experience begins, Now what i am trying to do is i make three pages, login.php logout.php

Regular expression tips or resources
Hello! I'm having some issues implementing the appropriate regex patter to eliminate unwanted charac

Weird Problem with curl while sending data
I am facing a weird problem with sending data to a site via curl.

If i send the value by this

show the direct link into href
I want to display link on the page. i am fetching the data(URL) from database,actually before that i

The repetition structure: the while statement not working
New programming student, have assignment as follows:
A restaurant has 4 lunch combos for custom

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

mysql query with single quotes in a variable
$sitedetails = "INSERT INTO vars (address, sitename, description, ownername, theme) VALUES ('$u

Slow data retrieval which requires improvement..please help
I am working on a Help Desk Ticketing system and have a page called MY TICKETS which shows all ticke

Word filter problem
Hello,

im trying to make a filter for words inputted in to my website but i want to store the

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