Forum Moderators: coopster

Message Too Old, No Replies

Running php script from server

Never done from command line before

         

mattyb515

3:18 pm on Jun 26, 2007 (gmt 0)

10+ Year Member



This morning I downloaded php and installed it on our server. It's not setup as a webserver b/c we didn't need that. Now this is probably a dumb question but how the heck do I run the scripts I've created. I've never done it from the command prompt before. Oh yeah it's a Windows 2K3 server. I've only ever run scripts from a website.

Thanks in advance all!

hawkerz

3:27 pm on Jun 26, 2007 (gmt 0)

10+ Year Member



just go start -> run and type in 'cmd'. Navigate to the directory the script is in using the cd command, and when you get there, type php scriptname.php

mattyb515

3:55 pm on Jun 26, 2007 (gmt 0)

10+ Year Member



That's what I though but I thought I should double check just to be sure.

When I run the script I receive an error that I haven't gotten before. It points to this line:

$data2 = fgetcsv($order_var_file, 1000, ",");

It expects parameter 1 to be resource and it says a boolean is given. I have this exact statement in 3 other places and I don't get an error. Any thoughts?

jatar_k

3:57 pm on Jun 26, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



where is $order_var_file defined? Also have you looked at whether you release the resource somewhere before this line?

If opening failed then you would get a bool

if $order_var_file is defined multiple times, such as opening and closing the file multiple times, then other places it is used becomes irrelevant

mattyb515

4:02 pm on Jun 26, 2007 (gmt 0)

10+ Year Member



It's defined at the beginning:

$order_var_file = fopen("$DOCUMENT_ROOT\live\incoming\order_variation.csv", "r");

I just find it kind of odd b/c this worked when I ran it from our webserver.

mattyb515

4:15 pm on Jun 26, 2007 (gmt 0)

10+ Year Member



I'm kind of lost b/c I just uploaded the script to our webserver and it ran beautifully.

$order_var_file = fopen("$DOCUMENT_ROOT\live\incoming\order_variation.csv", "r");

Do the backslashes need to be front slashes?

hawkerz

4:24 pm on Jun 26, 2007 (gmt 0)

10+ Year Member



you may need to use double \'s like C:\\location\\of\\file.csv

mattyb515

5:29 pm on Jun 26, 2007 (gmt 0)

10+ Year Member



The \\ was the ticket. Thanx so much.