NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: MyBrainIsFull on February 24, 2016, 08:15:11 PM
-
Hi all
I have 3 pcs on my network
A - MS Sql server
B - a MS Server 2008 SP2 with IIS & PHP installed
C - a MS Server 2008 with no iis - but has NTalk server
both B & C have a desktop app that can read the Ms Sql data on "A", so firewall is OK
I can get B & C to do simple php things, so php works, and with phpinfo.php I can see a section for "SQLSRV" so I believe the MS driver is installed on both as php_sqlsrv_54_nts.dll in the ext folder, and extension set in php.ini for this path.
But I cant access the MsSql data from either B or C using simple connection strings I have Googled to test the connection, I get a an error "Connection could not be established"
Has anyone been able to connect to MS Sql ? Any hints would be appreciated.
Thanks
PLEASE NOTE
THERE IS BEER AVAILABLE TO WHOEVER SOLVES THIS
-------[ Using SqlSrv_connect() shows echo 2 then throws error...
-------[ Using MsSql_connect() DOES NOT show echo 2 - it just plain dies
<?php
$serverName = "192.168.0.121,1433";
//$serverName = "s2003"; //serverName\instanceName
$connectionInfo = array( "Database"=>"BCDS_WMS", "UID"=>"sa", "PWD"=>"password");
// $conn = mssql_connect( $serverName, $connectionInfo);
$conn = sqlsrv_connect( $serverName, $connectionInfo);
echo " <br> 2..";
if( $conn ) {
echo "Connection established.<br />";
}else{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));
}
?>
==================[ UPDATE ]=========
Following the Googles I read it might need odbc installed, so I did and using odbc_connect( ) - this works OK - but still cant connect with sqlsrv_connect( ) which I need to use (to use customers php code)
<?php
$virtual_dsn = 'DRIVER={SQL Server};SERVER=s2003;DATABASE=BCDS_Wms';
$connection = odbc_connect($virtual_dsn,'sa','password') or die('ODBC Error:: '.odbc_error().' :: '.odbc_errormsg().' :: '.$virtual_dsn);
if ($connection){ echo "Good <p>" }
# query the users table for name and surname
$query = "SELECT id,barcode FROM Asset";
# perform the query
$result = odbc_exec($connection, $query);
# fetch the data from the database
while(odbc_fetch_row($result) ){
$id = odbc_result($result, 1);
$bcd = odbc_result($result, 2);
print("id=$id barcode $bcd<br>"); $x+=1;
}
# close the connection
odbc_close($connection);
?>
-
alas, I know nothing about PHP so I'm not the one to ask, but maybe someone else can chip in.
cheers
Bruce
-
what OS version?
-
thanks for the reply - bit of a mixture
ms sql is on server 2003
iis - I have 2 pcs that I have been trying, one is server 2008, and one is Win7
I cant see that the sql machine matters, its just a transaction to port 1433
Both Server 2012 and Win 7 box is running IIS 7 and php 5.4
I am running php 5.4 as I had endless troubles loading php 7 and gave up, started over again with 5.4
-
what version of SQL Server?
i think the problem is 2003 server and sqlclient recently i have a problem with server 2003 and c10 and NT, after move to server 2008 all work perfect.
try to install the correct sqlclient for sql version and force yours app to use driver in clarion is DRIVER={SQL Server Native Client 11.0} don't how in php
-
I now have Server 2008 running and it looks like the drivers are working as I no longer get that error, I have moved on to this error
Security Alert! The PHP CGI cannot be accessed directly.
This PHP CGI binary was compiled with force-cgi-redirect enabled. This means that a page will only be served up if the REDIRECT_STATUS CGI variable is set, e.g. via an Apache Action directive.
So I will try to understand this tomorrow
either to go back to Capesoft's 5.29 PHP in their example, and try to find drivers to suit 5.2. Perhaps it was compiled to allow direct access from a Net Talk Server
or
Find a way for NT to set this, as Google suggests setting the PHP.ini to allow direct access (but it didnt work for me)
cgi.redirect_status_env ='yes'
Thanks again for you suggestions
-
To osquiabro
Hi, thanks for your hints regarding PHP
I am still not getting Net Talk Server to send via php to a database and get a result.
Can you tell me please if you can do a SELECT and get a result set back via PHP ?
Would you mind sending me your PHP.INI as I think that this is where I am having trouble with some setting
Also - did you have to move the php-cgi.exe to another folder (the web folder) to avoid triggering the PHP redirection security alert?
Thanks for any help you can pass me.
-
hi, my hint is about sql server not php, i'm no expert in php, your primary problem is sql and no matter language is a same problem, so i think that san google is your best friend for your problem. ;D ;D ;D