[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 page is blank
Hi Everyone,

I have a site in which I am able to open the first PHP webpage in my browser but

"SEO" URLs
Hey, I'm wondering how to go about creating and using these types of URLs. I'm presuming it's PHP th

Edit MySQL Row Using PHP and HTML Form
Hello,

Here's what I'm trying to do. Build a page where a user enters a MySQL row number in.

Help with usergroups? prolly really quick
So were coding our own forums for a game system we made an we have the users level setup but now I n

php file erros / need help please
Hello

Someone decoded a zend file for me.. after uploaded it on ftp i get some errors, i trye

Click counter to ignore traffic from search bots
I have a click counter on my site that...well, counts the number of clicks a link gets on the frontp

is_dir() problem
Hello,

I'm buidling a php scripts that dynamically get's subfolders from a specific folder.

Strip Slashes Help
I've got a script that i've downloaded of the net to edit multiple fields from my sql database, and

Where do I put CRON code
So I've figured out alot about how to automatically run a php function. I can't figure out where to

Need help to modify php ELSE code
I'm trying to find a way to have the php code display a message if there is no inventory listed in 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