473,394 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Php+mssql

I am running PHP on one server (IIS), trying to connect to SQL Server on another server (all in-house, none available off campus). SQL Server Client has been loaded onto the box running PHP. My script stops at the mssql_connection() function, apparently not connecting to the other server. I've started working with the folks over at php.net, but I would appreciate any help I can get from anyone.
Mar 26 '07 #1
4 2793
I am running PHP on one server (IIS), trying to connect to SQL Server on another server (all in-house, none available off campus). SQL Server Client has been loaded onto the box running PHP. My script stops at the mssql_connection() function, apparently not connecting to the other server. I've started working with the folks over at php.net, but I would appreciate any help I can get from anyone.
why not try download wamp server which is all in one.. you get, php, mysql, apache all in one server
www.wampserver.com

TRY IT
Mar 27 '07 #2
ak1dnar
1,584 Expert 1GB
I am running PHP on one server (IIS), trying to connect to SQL Server on another server (all in-house, none available off campus). SQL Server Client has been loaded onto the box running PHP. My script stops at the mssql_connection() function, apparently not connecting to the other server. I've started working with the folks over at php.net, but I would appreciate any help I can get from anyone.
what is the error.? where is the coding.?
to help over i need to know about the connection string that you used to connect to mssql .post it here.
Mar 27 '07 #3
PHP + MS SQL Server – SUCCESS!

Thanks to all!

PHP is on an IIS server, SQL Server is on a different server in the same domain.

Changes made to PHP
o Add MS SQL Server Client Tools
o Uncomment the extension=php_mssql.dll statement in the php.ini file
o Add system variable PHPRC value c:\php
o Use ntwdblib.dll version 2000.80.194.0 (ver 2000.2.8.0 did not work); copied the files to c:\windows\system32 directory on the PHP server

Changes made to IIS
o Set up IUSER_machinename account with password

Changes made to MS SQL Server
o Create IUSER_machinename account with password – synchronize with IIS password
o Add IUSER as login
o Add IUSER as user on database, including permissions

After all of these steps were followed, the following PHP script ran correctly:

<html><head><title>MsSQL Table Viewer</title></head><body>
<?php
$db_host = hostname';
$db_user = 'username';
$db_pwd = 'password';
$database = 'dbname';
$table = 'tablename';

if (!mssql_connect($db_host, $db_user, $db_pwd))
die("Can't connect to database");
if (!mssql_select_db($database))
die("Can't select database");

// sending query
$result = mssql_query("SELECT * FROM {$table}");
if (!$result) {
die("Query to show fields from table failed");
}

$fields_num = mssql_num_fields($result);
echo "<h1>Table: {$table}</h1>";
echo "<table border='1'><tr>";
// printing table headersfor($i=0; $i<$fields_num; $i++)
{

$field = mssql_fetch_field($result);
echo "<td>{$field->name}</td>";
}
echo "</tr>\n";
// printing table rows

while($row = mssql_fetch_row($result))
{
echo "<tr>";

// $row is array... foreach( .. ) puts every element
// of $row to $cell variable

foreach($row as $cell)
echo "<td>$cell</td>";
echo "</tr>\n";
}
mssql_free_result($result);
?>

</body></html>
Mar 28 '07 #4
ak1dnar
1,584 Expert 1GB
Nice work!
Mar 29 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: marty | last post by:
I have a webpage that displays data from a SQL database in table format. I found information on how to create a way to allow a user to download this information to Excel using 'Header()' in the...
11
by: badz | last post by:
Hi frenz Lately I try to use MSSQL and PHP , the problem arise when PHP try to read MSSQL field with 'image' data type, header("Content-type: image/jpeg"); // act as a jpg file to browser I...
7
by: mj | last post by:
Hello, thanks for the help. I am running a WinXP Pro w/ SP2 (my home computer, with ZoneAlarm firewall) Apache 2.0.52 MySQL 4.1.7 PHP 5.1.0-dev I have developed a PHP/MySQL web app that...
0
by: dan | last post by:
Hi, I connect to a microsoft SQL server from php. Php is running on linux (debian sarge) with the freetds package. The connection is secured through stunnel (version 3.26), with stunnel running...
7
by: Mark Knochen | last post by:
Hallo, i have a MS SQL Database with some tables with textfields. in the textfields are long strings ... but i cant get the full string from the table ... i get only ca. 8000 chars ... Mark
1
by: Filipe Tomita | last post by:
Hi all, I have tried connect to remote MS SQL server with no success. Anyone help me? ###this is the code used to try connect $dsn = "Driver={SQL...
5
by: cecep | last post by:
hei, anyone! i need help to paging php using mssql, and php script in the program to make a next and previous button.. please sending message for me if you can answer my question
0
by: hassanali20 | last post by:
I've surfed this forum and found one thread which was talking about the same problem i've, but it didn't help in my situation. http://www.thescripts.com/forum/thread510563.html I could connect to...
6
by: SalokinX | last post by:
Hi everyone. I am trying to make a table that when people edit something from it, it will show the date it was edited. This is my code: $date = date("m/d/Y"); mssql_query("INSERT INTO news2...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.