I need to set a SQL connection string based on a PHP test code used to test the database
here is the string i have made(does not work)
"Data Source=something.com:3631;Initial Catalog=database;User Id=Neo;Password=qwerty;"
here is the test php file, Did i make something wrong?
note the php file does work
<?php
$dbname = 'database';
$server = 'something.com:3631';
$username = 'Neo';
$password = 'qwerty';
$sqlquery = "SELECT * FROM sometable ;";
$data = mssqlExec($sqlquery, $dbname, $server, $username, $password, $type=MSSQL_ASSOC);
print_r($data);
function mssqlExec($sqlquery, $dbname, $server, $username, $password, $type=MSSQL_ASSOC)
{
global $db_error;
$sqlconnect=mssql_connect($server,$username,$password);
if (!$sqlconnect) {
$db_error = "Could not Connect to $server";
return FALSE;
}
$sqldb=mssql_select_db($dbname,$sqlconnect);
$process=mssql_query($sqlquery);
if(!$process) {
$db_error = "Query did not return any results";
return FALSE;
}
$chk = substr($sqlquery, 0, 6);
if ($chk == 'SELECT') {
while ($row=mssql_fetch_array($process,$type)) {
foreach ($row as $colNum=>$value) {
$trimmed[$colNum] = trim($value);
}
$results[]=$trimmed;
}
} else {
$results = TRUE;
}
mssql_close($sqlconnect);
return $results;
}
?>
I am using MS Visual studio 2010 and ssql server 2008