Jump to content


This topic is now archived and is closed to further replies.


MSSQL Queries

Recommended Posts


So i am running MySQL and i have created a wep page that queries my db and shows me the results. No problem. But now i have a firend who wants the same but is running MSSQL.

I want too know is their any simple way in MSSQL too recrate the code below so i can perform the same tasks? If so how? Also how would one format it into individual rows?

Any help is much appreciated



//Connect too the database
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM archives ORDER BY id ASC";


echo "<b><center>Database Output</center></b><br><br>";

if ($num>5) {

while ($i < $to) {


echo "<b>$content</b>";



P.S Yes i realise that it's very simple and unformatted. But it serves it's purpose. And is on a closed network so having the user & pass in plain text isn't a problem :)

Also i dont want too setup ODBC or FreeTDS, (webserver accessing the MSSQL db is on a seprate pc running debian and MSSQL is running on a win2k3 box)


Share this post

Link to post
Share on other sites
Keep in mind that you'll have to enable the mssql extension in php.ini.

Changing between the 2 is very simple, however. Just change all the function calls to mssql_query (for example) instead of mysql_query. Also keep in mind that you won't have access to things like LIMIT/mysql_error().

Share this post

Link to post
Share on other sites


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.