[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

adding 0 to numbers
Hey guys i need to create a 00001 number in a loop. Is there a better way of forcing a 5 digit numbe

Last character removed
I have created a string from an array. I have inserted commas from my form values. I am trying to re

first few characters only
hi, does anyone know how to use PHP to take the first few words of a text and limit them? i have see

HTAccess auto log in?
Hi all.

Too busy driving celebs about lately so I hope someone here can help me out.

I

Casting Decimals in Oracle
This code worked as a query in DB2, but I am not sure what the syntax is for casting decimals in Ora

Implementing Single Sign-On using SAML 1.1, x.509, LDAP in C#.net
Hi, I got a requirement from the client i.e implementing single sing on using SAML 1.1( LDAP &

single values into sql field
i have a form which i want the user to able to select multiple answers. But i want the answers to be

Coding question?
Hey guys, I have a quick question. If I want to make a way for people to pay for health in my game,

Multiple WHILE loops help
Hi there. I'm writing an application that is pulling and displaying results for real estate listing

Execure stored procedure on a timer
Can someone tell me an easier way to execute a stored procedure on a timer? I am using Oracle 10g R

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