Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

php +connect sql server2000 +windows 2000 server

Posted on 2003-12-02
16
653 Views
Last Modified: 2007-12-19
I am php and sql server beginner. Please help. Blow is my code and error message. I like to connect to sql database. I am using windows 2000 server with sql server 2000. Thank you
<?
$link_ID = sql_connect("BK","dbo");                      
mysql_select_db("temp");                  

$result = mysql_query("select * from list;",$link_ID);  
$sn_index = mysql_num_rows($result);  

for ($index=0; $index < $sn_index ; $index++)
{
$arr[$index]= mysql_fetch_array($result);    
           
};

mysql_close($link_ID);  
?>

error message

Warning: mysql_connect(): Can't connect to MySQL server on 'BK' (10061)
0
Comment
Question by:jwaut
  • 7
  • 7
16 Comments
 
LVL 13

Accepted Solution

by:
lozloz earned 100 total points
ID: 9862782
hi,

that error message suggests you're using mysql_connect but your code shows sql_connect so i assume you were testing that out.. you need to use mssql_connect i think, with the arguments server name, username then password (http://uk2.php.net/mssql_connect)

then you can use the sql functions show on the left to interact with it (your mysql functions e.g. mysql_query, mysql_num_rows need to change to mssql versions)

cheers,

loz
0
 

Author Comment

by:jwaut
ID: 9863184
still does not work...

my code
<?
   $conn=mysql_connect("BK","administrator", '12345');
       if ($conn) {
       echo "Yeah i'm the best ;)";
   }
   else {
       echo "Woops ! ".mysql_get_last_message();
   }

?>

error message
Warning: mysql_connect(): Can't connect to MySQL server on 'BK' (10061) in c:\inetpub\wwwroot\test.php on line 2

Fatal error: Call to undefined function: mysql_get_last_message() in c:\inetpub\wwwroot\test.php on line 7

0
 
LVL 13

Expert Comment

by:lozloz
ID: 9863215
did you try hanging the functions mssql_*? you're using mysql there

loz
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:jwaut
ID: 9863378
ok..then error message will be

Fatal error: Call to undefined function: mssql_connect() in c:\inetpub\wwwroot\test.php on line 2

thank you
0
 
LVL 13

Expert Comment

by:lozloz
ID: 9863408
you need to follow the instructions here to install the extension for windows or linux - http://uk2.php.net/manual/en/ref.mssql.php

loz
0
 

Author Comment

by:jwaut
ID: 9863632
ok....in php.ini

original its like this
;extension=php_mssql.dll
I changed to
extension=php_mssql.dll

now error message is

Fatal error: Call to undefined function: mssql_connect() in c:\inetpub\wwwroot\test.php on line 2
PHP Warning: Unknown(): Unable to load dynamic library './php_mssql.dll' - The specified module could not be found. in Unknown on line 0

by the way, I am using 2000server with sql sever
and php is PHP Version 4.3.4.

THank you
0
 
LVL 13

Expert Comment

by:lozloz
ID: 9863688
from the manual:

The extension requires the MS SQL Client Tools to be installed on the system where PHP is installed. The Client Tools can be installed from the MS SQL Server CD or by copying ntwdblib.dll from \winnt\system32 on the server to \winnt\system32 on the PHP box. Copying ntwdblib.dll will only provide access. Configuration of the client will require installation of all the tools.

have you done that? looking the extensions folder of your php directory and see if php_mssql.dll is there as well

loz
0
 

Author Comment

by:jwaut
ID: 9868901
In the extensions folder of my php directory, there is no php_mssql.dll this file. How can I get this file? thank you
0
 
LVL 13

Expert Comment

by:lozloz
ID: 9869045
can you check winnt\system32 or windows\system32 for it

cheers,

loz
0
 

Author Comment

by:jwaut
ID: 9869082
I checked..nope..
0
 
LVL 13

Expert Comment

by:lozloz
ID: 9869173
ok download this then:

http://kromann.info/php4/php_mssql.dll

and put it in system32 folder and the extensions folder

loz
0
 

Author Comment

by:jwaut
ID: 9869256
thank you very much. I think its worked. But now the error message is
Warning: mssql_connect(): message: Login failed for user 'jessie'. Reason: Not associated with a trusted SQL Server connection. (severity 14)
thank you
0
 
LVL 13

Expert Comment

by:lozloz
ID: 9869362
this is about your mssql configuration, i've never used sql server before so can't really help here but you'll need to change the windows/sql server authentication levels

loz
0
 

Author Comment

by:jwaut
ID: 9869393
Thank you. You really helped me a lot.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
error while installing php56 in redhat enterprise linux 20 50
How to display div value on input field value in php 11 53
PHP and JQuery Syntax question 4 26
Ajax and PHP 9 29
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question