Jump to content

[SOLVED] PHP Command line help w/ db connection


bwcc

Recommended Posts

The following code works perfectly in a browser:

 

$server="xxxxxx";
$username="xxxxxx";
$password="xxxxxx";
$sqlconnect=mssql_connect($server, $username, $password);
$sqldb=mssql_select_db("msdatatest",$sqlconnect);
$date = mssql_fetch_array(mssql_query("SELECT CONVERT(VARCHAR(10), GETDATE(), 101) AS [MM/DD/YYYY]"));
$sql=mssql_query("SELECT WOnumber, Created, Property, UDF1 FROM tbl 
						WHERE Completed > (SELECT DATEADD(day, 0, (SELECT CONVERT(VARCHAR(10), GETDATE(), 101) AS [MM/DD/YYYY])))
						AND Status='Completed'");
require("class.phpmailer.php");
while ($row=mssql_fetch_array($sql)){
                   .................
             }

 

However, I'm wanting to schedule this script.  When using the command line executable, I get:

 

C:\web\mmweb>c:\php\php.exe xxxxxx.php

 

Warning: mssql_connect(): Unable to connect to server:  xxxxxx in C:\web\

mmweb\xxxxxx.php on line 5

 

Warning: mssql_select_db(): supplied argument is not a valid MS SQL-Link resourc

e in C:\web\mmweb\xxxxxx.php on line 6

 

This SQL server is remote to the PHP webserver.  Any help on this would be appreciated.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.