Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a VB.net based program and now want to create a "self-service" website to access the same information which is in MS SQL Server Management. I have the following code in the index.php file but when the site is loaded all that is shown is the welcome at the top. Anything I put in PHP before the attempt to connect shows but then after nothing is displayed, for example, in the code, there is 2 Echoed Welcomes, Only the 1st echo test is displayed. In the below code it technically should say "Couldnt connect to SQL Server on $Server" since I have random info as the connection but it doesn't echo anything.

PHP
<pre><?php

echo"Welcome";//*******************************1st Echo Test

$Server = "localhost";
$User = "your_name";
$Pass = "your_password";
$DB = "examples";

//connection to the database
$dbconn = mssql_connect($Server, $User, $Pass)
  or die("Couldn't connect to SQL Server on $Server");

//select a database to work with
$selected = mssql_select_db($DB, $dbconn)
  or die("Couldn't open database $myDB");

//declare the SQL statement that will query the database
$query = "SELECT name from test ";

//execute the SQL query and return records
$result = mssql_query($query);

$numRows = mssql_num_rows($result);
echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>";

//display the results
while($row = mssql_fetch_array($result))
{
  echo "<br>" . $row["name"];
}
//close the connection
mssql_close($dbconn);

echo"Welcome";//*******************************2nd Echo Test
?>



What I have tried:

I was looking into it and someone said to uncomment in the php.ini file the below statement which I did.

extension=php_pdo_mssql.dll

Uncommented it in the Developement and Production File.
Posted
Comments
Richard MacCutchan 30-Dec-19 4:31am    
You need to add some more echo statements to find out exactly where it stops.
phil.o 30-Dec-19 6:04am    
You should also restart the web service after having modified the php.ini file.
W Balboos, GHB 16-Jan-20 10:43am    
You can also download and install the free WAMP server, Vertrigo. MySQL support is built in. Plain SQL add-ons, available free from MicroSloth.

I've used it for years . . . run's half the company where I work on a single instance.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900