{"id":78969,"date":"2026-11-10T19:50:54","date_gmt":"2026-11-10T19:50:54","guid":{"rendered":"http:\/\/bangla.sitestree.com\/?p=78969"},"modified":"2026-11-10T19:56:56","modified_gmt":"2026-11-10T19:56:56","slug":"rewritten-sql-server-16205","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=78969","title":{"rendered":"Calling SQL Server Stored Procedures from Modern PHP: A Migration Tutorial"},"content":{"rendered":"<p>Old PHP code often used mssql_init, mssql_bind and mssql_execute. Those APIs are obsolete, but their basic goal\u2014calling a SQL Server stored procedure with typed parameters\u2014remains common.<\/p>\n<h2>Concepts and context<\/h2>\n<p>Use currently supported Microsoft PHP drivers such as SQLSRV or PDO_SQLSRV. Prepare a call, bind untrusted values as parameters, execute it, and fetch the result with appropriate error handling.<\/p>\n<h2>Practical application<\/h2>\n<p>With PDO_SQLSRV, a representative call is $stmt = $pdo-&gt;prepare(&#8216;EXEC dbo.GetCustomerById @CustomerID = ?&#8217;); $stmt-&gt;execute([123]);. Confirm that the procedure exists and its expected output matches the application. Test nullable outputs and multiple result sets separately.<\/p>\n<h2>Compatibility and cautions<\/h2>\n<p>Never migrate legacy mssql_* calls by mere renaming. Driver APIs and supported parameter directions differ. Use restricted service credentials, verified encryption, and secure exception handling.<\/p>\n<hr\/>\n<p><strong>AI and reuse disclosure:<\/strong> This newly written tutorial was generated with AI using <a href=\"https:\/\/bangla.sitestree.com\/?p=16205\">an existing Open Education article (post 16205)<\/a> as its starting point; explanations and examples may have been added. You may copy, edit and reuse the generated text with or without a reference. Rights in trademarks and third-party content remain with their respective owners. <strong>AI can make mistakes.<\/strong> Verify version compatibility, code and operational advice against current official documentation.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Old PHP code often used mssql_init, mssql_bind and mssql_execute. Those APIs are obsolete, but their basic goal\u2014calling a SQL Server stored procedure with typed parameters\u2014remains common.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[20,182],"tags":[466],"class_list":["post-78969","post","type-post","status-publish","format-standard","hentry","category-information-technology","category---blog","tag-sql-server","item-wrap"],"jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":16205,"url":"http:\/\/bangla.sitestree.com\/?p=16205","url_meta":{"origin":78969,"position":0},"title":"PHP SQL Server Stored Procedure","author":"Sayed","date":"September 21, 2019","format":false,"excerpt":"\/* prepare the statement resource *\/ $stmt=mssql_init(\"your_stored_procedure\", $conn); \/* now bind the parameters to it *\/ mssql_bind($stmt, \"@id\", $id, SQLINT4, FALSE); mssql_bind($stmt, \"@name\", $name, SQLVARCHAR, FALSE); mssql_bind($stmt, \"@email\", $email, SQLVARCHAR, FALSE); \/* now execute the procedure *\/ $result = mssql_execute($stmt); Another Example $conn = mssql_connect($db_host,$db_user,$db_password);if ($conn===false){ echo 'Cannot connect.'; exit;\u2026","rel":"","context":"In &quot;\u09ac\u09cd\u09b2\u0997 \u0964 Blog&quot;","block_context":{"text":"\u09ac\u09cd\u09b2\u0997 \u0964 Blog","link":"http:\/\/bangla.sitestree.com\/?cat=182"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26207,"url":"http:\/\/bangla.sitestree.com\/?p=26207","url_meta":{"origin":78969,"position":1},"title":"PHP SQL Server Stored Procedure #Root","author":"Author-Check- Article-or-Video","date":"April 19, 2021","format":false,"excerpt":"\/* prepare the statement resource *\/ $stmt=mssql_init(\"your_stored_procedure\", $conn); \/* now bind the parameters to it *\/ mssql_bind($stmt, \"@id\", $id, SQLINT4, FALSE); mssql_bind($stmt, \"@name\", $name, SQLVARCHAR, FALSE); mssql_bind($stmt, \"@email\", $email, SQLVARCHAR, FALSE); \/* now execute the procedure *\/ $result = mssql_execute($stmt); Another Example $conn = mssql_connect($db_host,$db_user,$db_password);if ($conn===false){ echo 'Cannot connect.'; exit;\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":70089,"url":"http:\/\/bangla.sitestree.com\/?p=70089","url_meta":{"origin":78969,"position":2},"title":"PHP SQL Server Stored Procedure #16","author":"Author-Check- Article-or-Video","date":"August 25, 2021","format":false,"excerpt":"\/* prepare the statement resource *\/$stmt=mssql_init(\"your_stored_procedure\", $conn);\/* now bind the parameters to it *\/mssql_bind($stmt, \"@id\", $id, SQLINT4, FALSE);mssql_bind($stmt, \"@name\", $name, SQLVARCHAR, FALSE);mssql_bind($stmt, \"@email\", $email, SQLVARCHAR, FALSE); \/* now execute the procedure *\/$result = mssql_execute($stmt); Another Example $conn = mssql_connect($db_host,$db_user,$db_password);if ($conn===false){ echo 'Cannot connect.'; exit;} if (mssql_select_db(\"YourDatabase\",$conn) === false) { echo\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":78935,"url":"http:\/\/bangla.sitestree.com\/?p=78935","url_meta":{"origin":78969,"position":3},"title":"PHP Functions for SQL Server: Historical MSSQL APIs and Supported Replacements","author":"Sayed","date":"November 10, 2026","format":false,"excerpt":"A historic PHP API family exposed functions beginning with mssql_, including connection management, result fetching, stored-procedure execution, and metadata inspection. That API is no longer suitable for modern PHP applications.","rel":"","context":"In &quot;Information Technology&quot;","block_context":{"text":"Information Technology","link":"http:\/\/bangla.sitestree.com\/?cat=20"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":78934,"url":"http:\/\/bangla.sitestree.com\/?p=78934","url_meta":{"origin":78969,"position":4},"title":"Calling SQL Server Stored Procedures from PHP: Modern Drivers and Examples","author":"Sayed","date":"November 10, 2026","format":false,"excerpt":"Early PHP applications commonly used mssql_connect, mssql_init, and mssql_bind. Those functions belonged to an obsolete extension and should not be copied into a new application.","rel":"","context":"In &quot;Information Technology&quot;","block_context":{"text":"Information Technology","link":"http:\/\/bangla.sitestree.com\/?cat=20"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":6093,"url":"http:\/\/bangla.sitestree.com\/?p=6093","url_meta":{"origin":78969,"position":5},"title":"\u09aa\u09bf\u098f\u0987\u099a\u09aa\u09bf \u09aa\u09cd\u09b0\u09bf\u09aa\u09c7\u09df\u09be\u09b0\u09cd\u09a1 \u09b8\u09cd\u099f\u09cd\u09af\u09be\u099f\u09ae\u09c7\u09a8\u09cd\u099f (PHP Prepared Statements in Bangla)","author":"Author-Check- Article-or-Video","date":"February 20, 2015","format":false,"excerpt":"\u09a1\u09be\u099f\u09be\u09ac\u09c7\u099c \u09ae\u09cd\u09af\u09be\u09a8\u09c7\u099c\u09ae\u09cd\u09af\u09be\u09a8\u09cd\u099f \u09b8\u09bf\u09b8\u09cd\u099f\u09c7\u09ae\u09c7 \u098f\u0995\u099f\u09bf \u09aa\u09cd\u09b0\u09bf\u09aa\u09c7\u09df\u09be\u09b0\u09cd\u09a1 \u09b8\u09cd\u099f\u09c7\u099f\u09ae\u09c7\u09a8\u09cd\u099f \u09b9\u09b2\u09cb \u098f\u09ae\u09a8 \u098f\u0995\u099f\u09bf \u09ab\u09bf\u099a\u09be\u09b0 \u09af\u09be \u098f\u0995\u0987 \u09ac\u09be \u098f\u0995\u0987 \u09a7\u09b0\u09a3\u09c7\u09b0 \u09a1\u09be\u099f\u09be\u09ac\u09c7\u099c \u09b8\u09cd\u099f\u09c7\u099f\u09ae\u09c7\u09a8\u09cd\u099f (\u09af\u09c7\u09ae\u09a8 SQL) \u09ac\u09be\u09b0\u09ac\u09be\u09b0 \u09a6\u0995\u09cd\u09b7\u09a4\u09be\u09b0 \u09b8\u09be\u09a5\u09c7 \u0985\u09cd\u09af\u09be\u0995\u099c\u09bf\u0995\u09bf\u0989\u099f \u0995\u09b0\u09a4\u09c7 \u09ac\u09cd\u09af\u09ac\u09b9\u09c3\u09a4 \u09b9\u09df\u0964 \u09b8\u09be\u09b0\u09cd\u09ad\u09be\u09b0 \u09b8\u09be\u0987\u09a1 \u09b8\u09cd\u0995\u09cd\u09b0\u09bf\u09aa\u09cd\u099f\u09bf\u0982 \u09ad\u09be\u09b7\u09be \u09aa\u09bf\u098f\u0987\u099a\u09aa\u09bf\u09a4\u09c7 (PHP) \u09aa\u09cd\u09b0\u09bf\u09aa\u09c7\u09df\u09be\u09b0\u09cd\u09a1 \u09b8\u09cd\u099f\u09c7\u099f\u09ae\u09c7\u09a8\u09cd\u099f\u0997\u09c1\u09b2\u09cb \u098f\u09b8\u0995\u09bf\u0989\u098f\u09b2 \u0987\u099e\u09cd\u099c\u09c7\u0995\u09b6\u09a8\u09c7\u09b0 \u09ac\u09bf\u09b0\u09c1\u09a6\u09cd\u09a7\u09c7 \u0996\u09c1\u09ac\u0987 \u0995\u09be\u09b0\u09cd\u09af\u0995\u09b0 \u09ad\u09c2\u09ae\u09bf\u0995\u09be \u09b0\u09be\u0996\u09c7\u0964 \u098f\u09b8\u0995\u09bf\u0989\u098f\u09b2 \u0987\u099e\u09cd\u099c\u09c7\u0995\u09b6\u09a8 \u09b9\u09b2\u09cb \u098f\u0995 \u09a7\u09b0\u09a3\u09c7\u09b0 \u0987\u099e\u09cd\u099c\u09c7\u0995\u09b6\u09a8 \u0995\u09cb\u09a1 \u09af\u09be \u09a1\u09be\u099f\u09be-\u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae\u0997\u09c1\u09b2\u09cb\u09a4\u09c7\u2026","rel":"","context":"In &quot;\u09aa\u09bf \u098f\u0987\u099a \u09aa\u09bf \u099f\u09bf\u0989\u099f\u09cb\u09b0\u09bf\u09df\u09be\u09b2 \u0964 PHP tutorial&quot;","block_context":{"text":"\u09aa\u09bf \u098f\u0987\u099a \u09aa\u09bf \u099f\u09bf\u0989\u099f\u09cb\u09b0\u09bf\u09df\u09be\u09b2 \u0964 PHP tutorial","link":"http:\/\/bangla.sitestree.com\/?cat=172"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/78969","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=78969"}],"version-history":[{"count":1,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/78969\/revisions"}],"predecessor-version":[{"id":79031,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/78969\/revisions\/79031"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=78969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=78969"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=78969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}