Jump to content

Recommended Posts

The following is the error I am receiving:

Warning: mssql_query(): message: Incorrect syntax near the keyword 'User'. (severity 15) in /var/www/try.php on line 25

 

I understand User is a protected keyword in SQL Server but how can I get past this? Do I have to surround the word user in specific characters? My code is below:

 

<?php
ini_set('display_errors', 1); 
ini_set('log_errors', 1); 
ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); 
error_reporting(E_ALL);
$con = mssql_connect('172.21.30.19', 'sa', 'nsn4hill');
if (!$con)
{
die('Could not connect: ' . mssql_error());
}

mssql_select_db("Intranet", $con);

$sql="SELECT CAST UserID AS TEXT FROM User";

$result = mssql_query($sql);

echo "<table border='1'>
<tr>
<COL width='100'>
<th bgcolor='black' style ='color:white'>Patch ID</th>
</tr>";

while($row = mssql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['UserID'] . "</td>";
echo "</tr>";
}
echo "</table>";

mssql_close($con);
?>

 

 

 

 

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.