| |

VerySource

 Forgot password?
 Register
Search
View: 689|Reply: 3

Ask PHP to connect to the SQL server!

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-1 10:40:01
| Show all posts |Read mode
$ connect = mssql_pconnect ("", "sa", "haha");
 mssql_select_db ("UserInfo", $ connect);

 $ query = "select * from UserInfo";
 $ result = mssql_query ($ query);
 $ rows = @mssql_num_rows ($ result);
 

 for ($ i = 0; $ i <$ rows; $ i ++) {
 @mssql_data_seek ($ result, $ i);
 $ data = @mssql_fetch_array ($ result);
echo "$ data [id] $ data [username] $ data [name]";
    
 }
 
 mssql_close ($ connect);



The code is as above, the data cannot be displayed using SQL authentication mode!
If you comment out the first line, the code runs normally. I guess php is connected using the windows login mode of sql server, but in actual applications, it should be connected using sql authentication mode.
Please friends who have experience in this area help!
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-13 16:15:01
| Show all posts
Modify the authentication method of MSSQL Server, and support both Windows authentication and SQL Server authentication.
Is ready to be modified using Enterprise Manager
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-3-14 23:30:01
| Show all posts
Sorry, the first line should be: $ connect = mssql_pconnect ("servername", "sa", "haha");

Please help, hurry ~~
Reply

Use magic Report

0

Threads

17

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

Post time: 2020-3-23 16:15:01
| Show all posts
The problem with the host address, right? Fill in 127.0.0.1 and try?
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list