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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.