<?php
$host = "Localhost";
$user = "User";
$pass = "Pass";
$db = "DB";
echo "<b>This will test your SQL Server connectivity...</b>";
/********** testing connectivity ***************/
echo"<font color = 'green'><br>connecting to Server....<P>";
$link = mssql_connect( $host, $user, $pass);
if( !$link )
{
die("<font color = 'red'><p>Failed to connect to server: database user name and/or password is invalid. </p>" . mssql_get_last_message(). "</font>");
}
/********** Selecting DB ***************/
echo "Selecting database.... <br>";
mssql_select_db($db) or die("<font color = 'red'><p>could not select database " . $db .", either it was not created, or user you are does not have access.</p>" . mssql_get_last_message(). "</font>");
/********** Running Select statement ***************/
echo "Selecting data.... <br>";
$query = "select * from User";
mssql_query($query) or die("<font color = 'red'><p>Data could not be retrieved. User may not have sufficient rights.</p>" . mssql_get_last_message(). "</font>");
echo"<p><B>testing is done, no errors detected </B></p></font>";
?>
output = This will test your SQL Server connectivity...
connecting to Server....
Selecting database....
Selecting data....
Data could not be retrieved. User may not have sufficient rights.
Incorrect syntax near the keyword 'User'.PHP Warning: mssql_query() [function.mssql-query]: message: Incorrect syntax near the keyword 'User'. (severity 15) in C:\wwwroot\0501161\test2.php on line 22 PHP Warning: mssql_query() [function.mssql-query]: Query failed in C:\wwwroot\0501161\test2.php on line 22
Real basic problems, but can't get php to do anything with mssql! any ideas i'm a real beginner the database and table exist and have data within it seems I can connect but not retreive any data with php. On annoying note I am making a back end to the site in Coldfusion and it will work with the database but too has limited functionality (although not as bad as the php)
Thanks in advance.
Boris