Start New Discussion within our Web Development Community

I'm making a PHP script for controlling my mssql databases. But I ran into a couple of problems.

The first problem is that I want to make a combobox out of all the databases in my microsoft SQL server. The following SQL syntax gives the results that I'm looking for, but I don't know how to place it into a combobox.

SELECT name from sys.databases where owner_sid != 0x01

My next problem is, that I have to run follwing SQL command:

RESTORE FILELISTONLY FROM DISK = 'C:\Databases\Breda\backup\Backup.BAK'

But I need to get the first column of every row, and place that in 2 variables, but I don't know how to do that.

Can anyone provide me this code?


$db = ADONewConnection(mssql_n);
$db->Connect('', 'sa', 'SAPB1Admin');

$query ="SELECT name from sys.databases";
$result = @mssql_query($query);

echo "<select name='database'><option value='default'>Choose a database</option>";
while ($row=mssql_fetch_array($result))

echo "<option value='" . $uid . "'>""</option>";
echo "</select>";


This is the code I wrote for my combobox, but when I run it, it doesn't give any output.

This article has been dead for over six months. Start a new discussion instead.