Results 1 to 12 of 12

Thread: PHP With SQL Server

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2007
    Posts
    912

    PHP With SQL Server

    hi all,
    i want to know how to connect php with MSSQL Server.
    i have installed Sql Server 2000 in my computer. i tried this function
    mssql_connect but im not able to connect please help me. please

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2007
    Posts
    912

    Re: PHP With SQL Server

    and please also tell me how can i get the USER name and password of my sql server for required parameter of mssql_connect function

  3. #3
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: PHP With SQL Server

    Quote Originally Posted by chunk
    hi all,
    i want to know how to connect php with MSSQL Server.
    i have installed Sql Server 2000 in my computer. i tried this function
    mssql_connect but im not able to connect please help me. please
    If I were psychic I might be able to tell the error message you received. Unfortunatly I am not so I am afraid you are going to have to post it.

    If you are having problems the PHP site is a good place to start:

    http://www.php.net/mssql/
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2007
    Posts
    912

    Re: PHP With SQL Server

    visualAd,

    thank you for your reply,
    my problem is when i run this code
    Code:
    <?php
    
    mssql_connect("localhost","root","");
    ?>
    i get two error msgs


    Warning: mssql_connect() [function.mssql-connect]: message: Login failed for user 'root'. Reason: Not associated with a trusted SQL Server connection. (severity 14) in C:\Program Files\EasyPHP 2.0b1\www\MSSQL\ms.php on line 4

    Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: localhost in C:\Program Files\EasyPHP 2.0b1\www\MSSQL\ms.php on line 4


    i know why im getting this msgs because i don't know what i have to write in the Required parameter
    i know my all the arguments are wrong in mssql_connect function. because i have never worked with SQL Server before thats y i want to know how can i get what should be Supplied in "USER" Argument and what should be supplied in "Password" argument and also i want to know what should be supplied in "Server" Argument.

    when i move my mouse pointer to the Tray Icon of MSSQL it shows

    Running - \\USER - MSSQLServer




    please help me

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: PHP With SQL Server

    Did you have a look at the link I sent you. More specifically: http://uk.php.net/function.mssql-connect. It tells you where to put the username and password when calling the function.

    You will need to use the credentials you use to connect normally or create a special account on SQL server for PHP.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2007
    Posts
    912

    Re: PHP With SQL Server

    yes i have read that but i dont know the proper values of the 3 required parameters
    can you tell me how can i get them?

  7. #7
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: PHP With SQL Server

    If you can't read the link I posted above then I can't help you.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  8. #8
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: PHP With SQL Server

    They are: Server - this is the name of the server where the database is. User - The login name of a user that has permissions to the database. Password - the password of the user specified in parameter 2.

    Now, if you STLL don't know what to put in there.... we can't help. We didn't setup your database.... if YOU didn't... grab the person that did. You might also want to think about a class or a book on how to manage SQL Server too... if you are going to be doing any amount of database work, this is stuff you are going to come up against time and time again.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2007
    Posts
    912

    Re: PHP With SQL Server

    i have read that and did everything i read there but still im not able to connect because i don't know what is the USERNAME and PASSWORD of my Sql server

    can you tell me how can i get the USER name of my sql server? this is the first time im using SQl server
    Code:
    <?php
    
    $h = mssql_connect(".","","");
    ?>
    if you think that im bothering you, you please dont waste your time in this thread

  10. #10
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: PHP With SQL Server

    The admin account is 'sa'. However, you should create user accounts for specific purposes and grant them appropriate permissions.

    This is really not a PHP topic. If you manage the SQL server then head over to the Database Development section and ask them there about setting up user accounts. If you don't manage the SQL server then ask the person who does for this information.

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2007
    Posts
    912

    Re: PHP With SQL Server

    Quote Originally Posted by penagate
    The admin account is 'sa'. However, you should create user accounts for specific purposes and grant them appropriate permissions.

    This is really not a PHP topic. If you manage the SQL server then head over to the Database Development section and ask them there about setting up user accounts. If you don't manage the SQL server then ask the person who does for this information.
    thanks again for being so kind to me penegate,
    actully one of my friend gave me SQL server 2000 CD and he told me to install it in my machine because i asked him for this.
    then i installed it in my machine and i just clicked on next, next... and then finish. i did not enter any password and also i did not enter any user name while installing SQL server.

    actully i want to learn how to work with SQL server And PHP instead of MySql.
    i tried this code
    Code:
    <?php
    
    $h = mssql_connect("local","sa","sa");
    ?>

    Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: local in C:\Program Files\EasyPHP 2.0b1\www\MSSQL\ms.php on line 4


    i just want to connect to SQL server and nothing else, same thing i want to do with Oracle but not now after few days.

    i really dont know what should i write in place of "LOCAL" in my above code. i have tried my computer name which is USER. you just please guide me where i can get these three parameter carefully so i can successfully connect to SQL server. if you tell me to install SQL server again then i will install it again as per your guidence

    please dont get irritated,

  12. #12
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: PHP With SQL Server

    If you jsut ran through the install w/o changing any thing, then the admin login is "sa" .. and the password is blank "". Again, I'd like to suggest a book on SQL Server. The one reason databases get hacked is because the sa account was left in it's default state (w/ no password). Even a basic book on SQL Server shoudl be able to provide a basic knowledge how it works, how to create users, and such.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width