I am having an issue with PHP. I can query from MSSMS directly to the DB but my web pages all will not...












-1















I am having an issue with PHP. I can query from MSSMS directly to the DB but my web pages all will not connect to the Server..



SQL Server 2016



PHP version 5.2.4
Sample:



$DatabaseServer =   'server';
$DatabaseUser = 'reader';
$DatabasePassword = '';
$DatabaseName = 'FSDBMV';

$SQL_db = @mssql_connect($DatabaseServer,$DatabaseUser,$DatabasePassword) or die("Unable to connect to Database server");
mssql_select_db("$DatabaseName");

$Sql = " SELECT [CustomerID]
,[CustomerName]
,[CSR]
,[CommissionCode]

FROM [FSDBMV].[dbo].[FS_Customer] as C









share|improve this question

























  • See mssql_get_last_message(). You need to find out why it's not working

    – Phil
    Nov 20 '18 at 1:20
















-1















I am having an issue with PHP. I can query from MSSMS directly to the DB but my web pages all will not connect to the Server..



SQL Server 2016



PHP version 5.2.4
Sample:



$DatabaseServer =   'server';
$DatabaseUser = 'reader';
$DatabasePassword = '';
$DatabaseName = 'FSDBMV';

$SQL_db = @mssql_connect($DatabaseServer,$DatabaseUser,$DatabasePassword) or die("Unable to connect to Database server");
mssql_select_db("$DatabaseName");

$Sql = " SELECT [CustomerID]
,[CustomerName]
,[CSR]
,[CommissionCode]

FROM [FSDBMV].[dbo].[FS_Customer] as C









share|improve this question

























  • See mssql_get_last_message(). You need to find out why it's not working

    – Phil
    Nov 20 '18 at 1:20














-1












-1








-1








I am having an issue with PHP. I can query from MSSMS directly to the DB but my web pages all will not connect to the Server..



SQL Server 2016



PHP version 5.2.4
Sample:



$DatabaseServer =   'server';
$DatabaseUser = 'reader';
$DatabasePassword = '';
$DatabaseName = 'FSDBMV';

$SQL_db = @mssql_connect($DatabaseServer,$DatabaseUser,$DatabasePassword) or die("Unable to connect to Database server");
mssql_select_db("$DatabaseName");

$Sql = " SELECT [CustomerID]
,[CustomerName]
,[CSR]
,[CommissionCode]

FROM [FSDBMV].[dbo].[FS_Customer] as C









share|improve this question
















I am having an issue with PHP. I can query from MSSMS directly to the DB but my web pages all will not connect to the Server..



SQL Server 2016



PHP version 5.2.4
Sample:



$DatabaseServer =   'server';
$DatabaseUser = 'reader';
$DatabasePassword = '';
$DatabaseName = 'FSDBMV';

$SQL_db = @mssql_connect($DatabaseServer,$DatabaseUser,$DatabasePassword) or die("Unable to connect to Database server");
mssql_select_db("$DatabaseName");

$Sql = " SELECT [CustomerID]
,[CustomerName]
,[CSR]
,[CommissionCode]

FROM [FSDBMV].[dbo].[FS_Customer] as C






php sql-server






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 '18 at 1:15









Phil

96.9k11139158




96.9k11139158










asked Nov 20 '18 at 1:12









kvngarnerkvngarner

43




43













  • See mssql_get_last_message(). You need to find out why it's not working

    – Phil
    Nov 20 '18 at 1:20



















  • See mssql_get_last_message(). You need to find out why it's not working

    – Phil
    Nov 20 '18 at 1:20

















See mssql_get_last_message(). You need to find out why it's not working

– Phil
Nov 20 '18 at 1:20





See mssql_get_last_message(). You need to find out why it's not working

– Phil
Nov 20 '18 at 1:20












1 Answer
1






active

oldest

votes


















1














Explanations:



First, remove error control operator @ and check for errors with mssql_get_last_message(). Then, execute your statement with mssql_query().



Example:



<?php
# Settings
$DatabaseServer = 'server';
$DatabaseUser = 'reader';
$DatabasePassword = '';
$DatabaseName = 'FSDBMV';

# Connection
$SQL_db = mssql_connect($DatabaseServer, $DatabaseUser, $DatabasePassword);
if ($SQL_db === false) {
echo "Error (mssql_connect): ".mssql_get_last_message();
exit;
}
if (!mssql_select_db($DatabaseName, $SQL_db)) {
echo "Error (mssql_select_db): ".mssql_get_last_message();
exit;
};

# Query
$Sql = "
SELECT
[CustomerID]
,[CustomerName]
,[CSR]
,[CommissionCode]
FROM [FSDBMV].[dbo].[FS_Customer] as C
";
$stmt = mssql_query($Sql, $SQL_db);
if (!$stmt) {
echo "Error (mssql_query): ".mssql_get_last_message();
exit;
}

# Results
while ($row = mssql_fetch_assoc($stmt)) {
echo print_r($row, true)."</br>";
}

# End
mssql_free_result($stmt);
mssql_close($SQL_db);
?>


Notes:



MSSQL feature was removed in PHP 7.0. Consider another way to connect to MS SQL Server.






share|improve this answer


























  • Thank you for the response. I got the same error as with the original code. "Fatal error: Uncaught Error: Call to undefined function mssql_connect() in C:xampphtdocstest.php:10 Stack trace: #0 {main} thrown in C:xampphtdocstest.php on line 10"

    – kvngarner
    Nov 20 '18 at 12:34








  • 1





    @kvngarner Your mssql extension is not installed correctly.

    – Zhorov
    Nov 20 '18 at 12:37











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53384853%2fi-am-having-an-issue-with-php-i-can-query-from-mssms-directly-to-the-db-but-my%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Explanations:



First, remove error control operator @ and check for errors with mssql_get_last_message(). Then, execute your statement with mssql_query().



Example:



<?php
# Settings
$DatabaseServer = 'server';
$DatabaseUser = 'reader';
$DatabasePassword = '';
$DatabaseName = 'FSDBMV';

# Connection
$SQL_db = mssql_connect($DatabaseServer, $DatabaseUser, $DatabasePassword);
if ($SQL_db === false) {
echo "Error (mssql_connect): ".mssql_get_last_message();
exit;
}
if (!mssql_select_db($DatabaseName, $SQL_db)) {
echo "Error (mssql_select_db): ".mssql_get_last_message();
exit;
};

# Query
$Sql = "
SELECT
[CustomerID]
,[CustomerName]
,[CSR]
,[CommissionCode]
FROM [FSDBMV].[dbo].[FS_Customer] as C
";
$stmt = mssql_query($Sql, $SQL_db);
if (!$stmt) {
echo "Error (mssql_query): ".mssql_get_last_message();
exit;
}

# Results
while ($row = mssql_fetch_assoc($stmt)) {
echo print_r($row, true)."</br>";
}

# End
mssql_free_result($stmt);
mssql_close($SQL_db);
?>


Notes:



MSSQL feature was removed in PHP 7.0. Consider another way to connect to MS SQL Server.






share|improve this answer


























  • Thank you for the response. I got the same error as with the original code. "Fatal error: Uncaught Error: Call to undefined function mssql_connect() in C:xampphtdocstest.php:10 Stack trace: #0 {main} thrown in C:xampphtdocstest.php on line 10"

    – kvngarner
    Nov 20 '18 at 12:34








  • 1





    @kvngarner Your mssql extension is not installed correctly.

    – Zhorov
    Nov 20 '18 at 12:37
















1














Explanations:



First, remove error control operator @ and check for errors with mssql_get_last_message(). Then, execute your statement with mssql_query().



Example:



<?php
# Settings
$DatabaseServer = 'server';
$DatabaseUser = 'reader';
$DatabasePassword = '';
$DatabaseName = 'FSDBMV';

# Connection
$SQL_db = mssql_connect($DatabaseServer, $DatabaseUser, $DatabasePassword);
if ($SQL_db === false) {
echo "Error (mssql_connect): ".mssql_get_last_message();
exit;
}
if (!mssql_select_db($DatabaseName, $SQL_db)) {
echo "Error (mssql_select_db): ".mssql_get_last_message();
exit;
};

# Query
$Sql = "
SELECT
[CustomerID]
,[CustomerName]
,[CSR]
,[CommissionCode]
FROM [FSDBMV].[dbo].[FS_Customer] as C
";
$stmt = mssql_query($Sql, $SQL_db);
if (!$stmt) {
echo "Error (mssql_query): ".mssql_get_last_message();
exit;
}

# Results
while ($row = mssql_fetch_assoc($stmt)) {
echo print_r($row, true)."</br>";
}

# End
mssql_free_result($stmt);
mssql_close($SQL_db);
?>


Notes:



MSSQL feature was removed in PHP 7.0. Consider another way to connect to MS SQL Server.






share|improve this answer


























  • Thank you for the response. I got the same error as with the original code. "Fatal error: Uncaught Error: Call to undefined function mssql_connect() in C:xampphtdocstest.php:10 Stack trace: #0 {main} thrown in C:xampphtdocstest.php on line 10"

    – kvngarner
    Nov 20 '18 at 12:34








  • 1





    @kvngarner Your mssql extension is not installed correctly.

    – Zhorov
    Nov 20 '18 at 12:37














1












1








1







Explanations:



First, remove error control operator @ and check for errors with mssql_get_last_message(). Then, execute your statement with mssql_query().



Example:



<?php
# Settings
$DatabaseServer = 'server';
$DatabaseUser = 'reader';
$DatabasePassword = '';
$DatabaseName = 'FSDBMV';

# Connection
$SQL_db = mssql_connect($DatabaseServer, $DatabaseUser, $DatabasePassword);
if ($SQL_db === false) {
echo "Error (mssql_connect): ".mssql_get_last_message();
exit;
}
if (!mssql_select_db($DatabaseName, $SQL_db)) {
echo "Error (mssql_select_db): ".mssql_get_last_message();
exit;
};

# Query
$Sql = "
SELECT
[CustomerID]
,[CustomerName]
,[CSR]
,[CommissionCode]
FROM [FSDBMV].[dbo].[FS_Customer] as C
";
$stmt = mssql_query($Sql, $SQL_db);
if (!$stmt) {
echo "Error (mssql_query): ".mssql_get_last_message();
exit;
}

# Results
while ($row = mssql_fetch_assoc($stmt)) {
echo print_r($row, true)."</br>";
}

# End
mssql_free_result($stmt);
mssql_close($SQL_db);
?>


Notes:



MSSQL feature was removed in PHP 7.0. Consider another way to connect to MS SQL Server.






share|improve this answer















Explanations:



First, remove error control operator @ and check for errors with mssql_get_last_message(). Then, execute your statement with mssql_query().



Example:



<?php
# Settings
$DatabaseServer = 'server';
$DatabaseUser = 'reader';
$DatabasePassword = '';
$DatabaseName = 'FSDBMV';

# Connection
$SQL_db = mssql_connect($DatabaseServer, $DatabaseUser, $DatabasePassword);
if ($SQL_db === false) {
echo "Error (mssql_connect): ".mssql_get_last_message();
exit;
}
if (!mssql_select_db($DatabaseName, $SQL_db)) {
echo "Error (mssql_select_db): ".mssql_get_last_message();
exit;
};

# Query
$Sql = "
SELECT
[CustomerID]
,[CustomerName]
,[CSR]
,[CommissionCode]
FROM [FSDBMV].[dbo].[FS_Customer] as C
";
$stmt = mssql_query($Sql, $SQL_db);
if (!$stmt) {
echo "Error (mssql_query): ".mssql_get_last_message();
exit;
}

# Results
while ($row = mssql_fetch_assoc($stmt)) {
echo print_r($row, true)."</br>";
}

# End
mssql_free_result($stmt);
mssql_close($SQL_db);
?>


Notes:



MSSQL feature was removed in PHP 7.0. Consider another way to connect to MS SQL Server.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 20 '18 at 11:22

























answered Nov 20 '18 at 6:58









ZhorovZhorov

3,5042517




3,5042517













  • Thank you for the response. I got the same error as with the original code. "Fatal error: Uncaught Error: Call to undefined function mssql_connect() in C:xampphtdocstest.php:10 Stack trace: #0 {main} thrown in C:xampphtdocstest.php on line 10"

    – kvngarner
    Nov 20 '18 at 12:34








  • 1





    @kvngarner Your mssql extension is not installed correctly.

    – Zhorov
    Nov 20 '18 at 12:37



















  • Thank you for the response. I got the same error as with the original code. "Fatal error: Uncaught Error: Call to undefined function mssql_connect() in C:xampphtdocstest.php:10 Stack trace: #0 {main} thrown in C:xampphtdocstest.php on line 10"

    – kvngarner
    Nov 20 '18 at 12:34








  • 1





    @kvngarner Your mssql extension is not installed correctly.

    – Zhorov
    Nov 20 '18 at 12:37

















Thank you for the response. I got the same error as with the original code. "Fatal error: Uncaught Error: Call to undefined function mssql_connect() in C:xampphtdocstest.php:10 Stack trace: #0 {main} thrown in C:xampphtdocstest.php on line 10"

– kvngarner
Nov 20 '18 at 12:34







Thank you for the response. I got the same error as with the original code. "Fatal error: Uncaught Error: Call to undefined function mssql_connect() in C:xampphtdocstest.php:10 Stack trace: #0 {main} thrown in C:xampphtdocstest.php on line 10"

– kvngarner
Nov 20 '18 at 12:34






1




1





@kvngarner Your mssql extension is not installed correctly.

– Zhorov
Nov 20 '18 at 12:37





@kvngarner Your mssql extension is not installed correctly.

– Zhorov
Nov 20 '18 at 12:37


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53384853%2fi-am-having-an-issue-with-php-i-can-query-from-mssms-directly-to-the-db-but-my%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Can I use Tabulator js library in my java Spring + Thymeleaf project?