I'm in the middle of migrating a Linux server to a Windows server. In the process I need to change over the databases from MySQL to MSSQL. I'm not 'overly familiar' with MSSQL so kind of learning on the job. Anyway, I'm having a little trouble with a query throwing out the following error: Warning: mssql_query(): supplied argument is not a valid MS SQL-Link resource in D:\... on line 47 Warning: mssql_num_rows(): supplied argument is not a valid MS SQL-result resource in D:\... on line 51 Warning: mssql_fetch_array(): supplied argument is not a valid MS SQL-result resource in D:\... on line 60 PHP: It's this section of code causing the problem: $resultb = mssql_query(" SELECT id, title, url FROM cat_objects WHERE parent_id = ",$resultRow['id']," ORDER BY title ASC "); PHP: Full code: <?php //GET CATEGORIES $numCols = 2; $result = mssql_query(" SELECT id, title, url FROM categories "); //Count number of rows and divide into 2 $numPerCol = ceil(mssql_num_rows($result) / $numCols); echo "<div style=\"width:364px;\">\n"; for($col = 1; $col <= $numCols; $col++) { echo "<div style=\"width:100%;float:left;margin-left:5px;\">"; for($row = 0; $row < $numPerCol; $row++) { $resultRow = mssql_fetch_assoc($result); if($resultRow == false) { break; } //Output data echo '<h3>',$resultRow['title'],'</h3>'; //Get subcategories $resultb = mssql_query(" SELECT id, title, url FROM cat_objects WHERE parent_id = ",$resultRow['id']," ORDER BY title ASC "); //Check if no results if(mssql_num_rows($resultb)==0){ $message = "There are no subcategories"; } else { $message = ""; } while($rowb = mssql_fetch_array($resultb)) //Add comma to all but last result { if ($count++ > 0) echo " | "; echo "<a href=\"cat.php?id=",$rowb['urlb'],"\" title=\"$titleb\">",$rowb['title'],"</a>"; } echo "$message <br /><br />"; } echo "\n</div>\n"; } echo "</div>\n"; ?> PHP: Help greatly appreciated.
Issue fixed. Code for anybody experiencing similar issues: <?php //GET CATEGORIES $numCols = 2; $result = mssql_query(" SELECT id, title, url FROM categories "); //Count number of rows and divide into 2 $numPerCol = ceil(mssql_num_rows($result) / $numCols); echo "<div style=\"width:364px;\">\n"; for($col = 1; $col <= $numCols; $col++) { echo "<div style=\"width:100%;margin-left:5px;\">"; for($row = 0; $row < $numPerCol; $row++) { $resultRow = mssql_fetch_assoc($result); if($resultRow == false) { break; } //Output data echo '<h3>',$resultRow['title'],'</h3>'; //Get subcategories $resultb = mssql_query(" SELECT id, title, url FROM cat_objects WHERE parent_id = " . $resultRow['id'] . " "); //Check if no results if(mssql_num_rows($resultb)==0){ $message = "No categories yet."; } else { $message = ""; } while($rowb = mssql_fetch_array($resultb)) //Add space to all but last result { if ($count++ > 1) echo " "; echo "<a href=\"cat.php?id=",$rowb['urlb'],"\" title=\"$titleb\">",$rowb['title'],"</a>"; } echo "$message <br /><br />"; } echo "\n</div>\n"; } echo "</div>\n"; ?> PHP: