PHP MYSQL Load Data Error


I am having a heck of a time with this, I had it working just fine but moved to another server and it is giving me error 13 even with all of the same permissions set.

I was told that I can try to transfer the file to the 'temp' folder and would have a better chance getting it to work.

Can someone please take a look at the code below and let me know how to transfer it to the /temp/ folder and run the file from there.

Here is what my current error is:
Can't get stat of '/var/www/vhosts/' (Errcode: 13)

The user has 'file' permissions
The current folder and file have 777 permissions

Below is the code I am using.

Thanks for any help.

mysql_query("TRUNCATE TABLE vehicle_data_processing") or die(mysql_error());

$loadsql = 'LOAD DATA INFILE "../../../var/www/vhosts/" INTO TABLE vehicle_data_processing
FIELDS TERMINATED BY "|" LINES TERMINATED BY "\n" IGNORE 1 LINES (dealer_id, company_name, company_address, company_city, company_state, company_zip);';
mysql_query($loadsql) or die(mysql_error());	


echo 'Updated the Processing Table<br>';

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Based on the "cannot stat" error, I assume it is the copy that is throwing you off.

copy, natively, does not support FTP. Perhaps the other server had a configuration that allowed you to open an FTP destination as a file handle?

In case I am wrong on that, have you checked file permissions all the way up?
Turns out I am wrong on that one. Never seen that usage before.
In looking at your copy statement, this leads me to believe that there are three servers in the topography. a source, a destination, and the man-in-the-middle that is actually running the PHP script. Is this true?

However, that being said, the rest of your code leads me to believe that there are only two: a source, and a destination where the PHP script is running.

If that is the case, then instead of using ftp:// on the destination, just change your desitnation to '/tmp/dump.sql'

Then load everything from /tmp/dump.sql.

Be careful about this though.... /tmp/ gets emptied on reboot.
This line is also problematic:

$loadsql = 'LOAD DATA INFILE "../../../var/www/vhosts/" INTO TABLE vehicle_data_processing

there should not be ../../../ in front of a a /var/www/ unless you have something special configured.

It should just be /var/www/vhosts/

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
movieprodwAuthor Commented:
Thanks for your input, it turns out that there were 2 errors, one is that the ftp copy issue was not resulting in a complete copy of the file for some reason and the second issue was that I did not have the proper permissions set on the httpdocs folder, I set it to 750 and it works great.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.