I have this piece that is not working right and I can't figure out what I am doing wrong. Anny assistance would be greatly appreciated.
<?php
$serverquery = "SELECT svr_name FROM svr";
$serverresult = mssql_query($serverquery);
while (list($server_name) = mssql_fetch_row($serverresult))
{
print "$server_name<br>";
$server_table = svr_.strtolower($server_name);
$drivequery = "SELECT drv_ltr FROM '$server_table'";
$driveresult = mssql_query($drivequery);
while (list($drive_letter) = mssql_fetch_row($driveresult))
{
print "$drive_letter<br>";
}
}
?>
This is the error I get
Warning: mssql_query() [function.mssql-query]: message: Line 1: Incorrect syntax near 'svr_server-01'. (severity 15) in C:\Inetpub\ConfigMgmt\phpinfo.php on line 30
Warning: mssql_query() [function.mssql-query]: Query failed in C:\Inetpub\ConfigMgmt\phpinfo.php on line 30
Warning: mssql_fetch_row(): supplied argument is not a valid MS SQL-result resource in C:\Inetpub\ConfigMgmt\phpinfo.php on line 31
This line (line 30):
$drivequery = "SELECT drv_ltr FROM '$server_table'";
is what it keeps hanging up. I tried removing the single quotes from the server_table variable and it changes the error to the following.
Warning: mssql_query() [function.mssql-query]: message: Line 1: Incorrect syntax near '-'. (severity 15) in C:\Inetpub\ConfigMgmt\phpinfo.php on line 30
Warning: mssql_query() [function.mssql-query]: Query failed in C:\Inetpub\ConfigMgmt\phpinfo.php on line 30
Warning: mssql_fetch_row(): supplied argument is not a valid MS SQL-result resource in C:\Inetpub\ConfigMgmt\phpinfo.php on line 31
I am kind of new to sql and php so I am hoping it is something silly.