0
<?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

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by tesuji
0

Hi

who is OWNER of table user in: "select * from User" ?

If dbo, then "select * from dbo.User"


Aha, and not forgetting: "User" is a reserved keyword in SQL server which is not allowed to get redefined by you.

Btw, there isn't any system table "User" which contains the names and PASSWORDS of SQL Server users ;) (that would be really too simplistic!)

-- tesu

Edited by tesuji: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.