Jump to content

Accessing MSSQL with PHP


phpjoy

Recommended Posts

Hi, I am trying to access the SQL Server 2005 with PHP. For that I have activated IIS 7 on the windows small business server, for PHP. Now I have the following code for local web hosting :

 

=====================================

 

 

<head>

<meta http-equiv="refresh" content="2";url="index.php";>

<title>Trial 1</title>

 

</head>

<h1>

:: B List ::

</h1>

 

 

<?php

 

$now = time();

echo $now;

 

$link = mssql_connect("SRVR name", "local host \ user name", "password");

 

if (!$link)

{

die('ERROR: Could not connect');

}

 

 

mssql_select_db('database name', $link);

 

 

$query = mssql_query('SELECT B_No, FROM dbo.B_LIST WHERE B_No = 000011', $link);

 

if (!$query)

{

die('MSSQL error');

}

 

$row = mssql_fetch_row ($query);

 

 

echo $row;

 

 

?>

 

 

<body>

</body>

</html>

=========================================

 

In this I am just trying to print one row from the database on the webpage

Correct me if I am wrong, as I am coding PHP for the first time with online help.

 

When I try to access the webpage on the explorer I only get the title and the page if refreshed every 2 seconds , and the time is displayed. Nothing is available from database.

 

Thank you.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.