connecting to a mssql database

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Advo

    connecting to a mssql database

    Im having major problems trying to connect to a mssql database thats
    hosted on our server.

    I've got the ip, username, password and database name, yet no matter
    what i try, I cant seem to connect. I've trawled the net for hours
    looking for code, has anyone got any that definately works, or just a
    simple way I can check the connection.


    Thanks

  • Kim André Akerø

    #2
    Re: connecting to a mssql database

    Advo wrote:
    Im having major problems trying to connect to a mssql database thats
    hosted on our server.
    >
    I've got the ip, username, password and database name, yet no matter
    what i try, I cant seem to connect. I've trawled the net for hours
    looking for code, has anyone got any that definately works, or just a
    simple way I can check the connection.
    I don't know how you've tried it, but you should be doing something
    like this in your code:

    mysql_connect($ ip, $username, $password);
    mysql_select_db ($database);

    You should also be doing this on the server, and not directly from
    home. Security settings on the database server will only allow
    connections from a certain IP (or IP range).

    --
    Kim André Akerø
    - kimandre@NOSPAM betadome.com
    (remove NOSPAM to contact me directly)

    Comment

    • Jerry Stuckle

      #3
      Re: connecting to a mssql database

      Kim André Akerø wrote:
      Advo wrote:
      >
      >
      >>Im having major problems trying to connect to a mssql database thats
      >>hosted on our server.
      >>
      >>I've got the ip, username, password and database name, yet no matter
      >>what i try, I cant seem to connect. I've trawled the net for hours
      >>looking for code, has anyone got any that definately works, or just a
      >>simple way I can check the connection.
      >
      >
      I don't know how you've tried it, but you should be doing something
      like this in your code:
      >
      mysql_connect($ ip, $username, $password);
      mysql_select_db ($database);
      >
      You should also be doing this on the server, and not directly from
      home. Security settings on the database server will only allow
      connections from a certain IP (or IP range).
      >
      Except he's using MS SQL Server, not MySQL. But the statements are the
      same - just substitute 'mssql' for 'mysql'.

      It's hard to say without knowing what error messages you get. Did you
      check the user notes for mssql_connect at
      http://www.php.net/manual/en/functio...l-connect.php? They contain
      some good information.

      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      • Chung Leong

        #4
        Re: connecting to a mssql database

        Advo wrote:
        Im having major problems trying to connect to a mssql database thats
        hosted on our server.
        >
        I've got the ip, username, password and database name, yet no matter
        what i try, I cant seem to connect. I've trawled the net for hours
        looking for code, has anyone got any that definately works, or just a
        simple way I can check the connection.
        >
        >
        Thanks
        What platform is PHP running on? What version of PHP? What API are you
        using? Are you using integrated security? What version of SQL Server?
        Without more information no one will be able to help you.

        Comment

        • Advo

          #5
          Re: connecting to a mssql database

          Heres some actual code i've tried:

          <?php
          echo "here";
          $cs = mssql_connect ( 'ip...', 'administrator' , 'pass' ) or die('Could
          not connect: ' . mssql_get_last_ message());
          echo "here2";



          then i run my page, and all it says is "here"

          nothing else

          Comment

          • Advo

            #6
            Re: connecting to a mssql database

            php etc is installed on our hosting, so not sure about that, i could
            possibly look into it if needs be. I just develop the php files, and
            then upload to our fasthosts dedicated server.. but we are running
            Microsoft SQL Server 2000 on our server..


            Chung Leong wrote:
            Advo wrote:
            Im having major problems trying to connect to a mssql database thats
            hosted on our server.

            I've got the ip, username, password and database name, yet no matter
            what i try, I cant seem to connect. I've trawled the net for hours
            looking for code, has anyone got any that definately works, or just a
            simple way I can check the connection.


            Thanks
            >
            What platform is PHP running on? What version of PHP? What API are you
            using? Are you using integrated security? What version of SQL Server?
            Without more information no one will be able to help you.

            Comment

            • Chung Leong

              #7
              Re: connecting to a mssql database


              Advo wrote:
              Heres some actual code i've tried:
              >
              <?php
              echo "here";
              $cs = mssql_connect ( 'ip...', 'administrator' , 'pass' ) or die('Could
              not connect: ' . mssql_get_last_ message());
              echo "here2";
              >
              >
              >
              then i run my page, and all it says is "here"
              >
              nothing else
              Looks like the mssql extension wasn't turned on. Your script is dying
              with a undefined function error.

              Comment

              • Jerry Stuckle

                #8
                Re: connecting to a mssql database

                Advo wrote:
                php etc is installed on our hosting, so not sure about that, i could
                possibly look into it if needs be. I just develop the php files, and
                then upload to our fasthosts dedicated server.. but we are running
                Microsoft SQL Server 2000 on our server..
                >
                >
                Chung Leong wrote:
                >
                >
                >>Advo wrote:
                >>
                >>>Im having major problems trying to connect to a mssql database thats
                >>>hosted on our server.
                >>>
                >>>I've got the ip, username, password and database name, yet no matter
                >>>what i try, I cant seem to connect. I've trawled the net for hours
                >>>looking for code, has anyone got any that definately works, or just a
                >>>simple way I can check the connection.
                >>>
                >>>
                >>>Thanks
                >>
                >>What platform is PHP running on? What version of PHP? What API are you
                >>using? Are you using integrated security? What version of SQL Server?
                >>Without more information no one will be able to help you.
                >
                >
                Turn on all errors and display them to see what you're getting:

                ini_set('displa y_errors', '1');
                error_reporting (E_ALL);

                And phpinfo() will tell you if the mssql extensions are loaded in PHP.

                Just having SQL Server on the system isn't enough. You also have to
                enable it in php.

                --
                =============== ===
                Remove the "x" from my email address
                Jerry Stuckle
                JDS Computer Training Corp.
                jstucklex@attgl obal.net
                =============== ===

                Comment

                • Advo

                  #9
                  Re: connecting to a mssql database


                  Jerry Stuckle wrote:
                  Advo wrote:
                  php etc is installed on our hosting, so not sure about that, i could
                  possibly look into it if needs be. I just develop the php files, and
                  then upload to our fasthosts dedicated server.. but we are running
                  Microsoft SQL Server 2000 on our server..


                  Chung Leong wrote:

                  >Advo wrote:
                  >
                  >>Im having major problems trying to connect to a mssql database thats
                  >>hosted on our server.
                  >>
                  >>I've got the ip, username, password and database name, yet no matter
                  >>what i try, I cant seem to connect. I've trawled the net for hours
                  >>looking for code, has anyone got any that definately works, or just a
                  >>simple way I can check the connection.
                  >>
                  >>
                  >>Thanks
                  >
                  >What platform is PHP running on? What version of PHP? What API are you
                  >using? Are you using integrated security? What version of SQL Server?
                  >Without more information no one will be able to help you.
                  >
                  Turn on all errors and display them to see what you're getting:
                  >
                  ini_set('displa y_errors', '1');
                  error_reporting (E_ALL);
                  >
                  And phpinfo() will tell you if the mssql extensions are loaded in PHP.
                  >
                  Just having SQL Server on the system isn't enough. You also have to
                  enable it in php.
                  >
                  --
                  =============== ===
                  Remove the "x" from my email address
                  Jerry Stuckle
                  JDS Computer Training Corp.
                  jstucklex@attgl obal.net
                  =============== ===



                  yea i think thats the problem because ive got this now, with errors
                  turned on:

                  start
                  Fatal error: Call to undefined function mssql_connect() in
                  /home/default/site/user/htdocs/testmssql.php on line 5



                  so basically i need to do extension=php_m ssql.dll in my php.ini?

                  Comment

                  • Jerry Stuckle

                    #10
                    Re: connecting to a mssql database

                    Advo wrote:
                    Jerry Stuckle wrote:
                    >
                    >>Advo wrote:
                    >>
                    >>>php etc is installed on our hosting, so not sure about that, i could
                    >>>possibly look into it if needs be. I just develop the php files, and
                    >>>then upload to our fasthosts dedicated server.. but we are running
                    >>>Microsoft SQL Server 2000 on our server..
                    >>>
                    >>>
                    >>>Chung Leong wrote:
                    >>>
                    >>>
                    >>>
                    >>>>Advo wrote:
                    >>>>
                    >>>>
                    >>>>>Im having major problems trying to connect to a mssql database thats
                    >>>>>hosted on our server.
                    >>>>>
                    >>>>>I've got the ip, username, password and database name, yet no matter
                    >>>>>what i try, I cant seem to connect. I've trawled the net for hours
                    >>>>>looking for code, has anyone got any that definately works, or just a
                    >>>>>simple way I can check the connection.
                    >>>>>
                    >>>>>
                    >>>>>Thanks
                    >>>>
                    >>>>What platform is PHP running on? What version of PHP? What API are you
                    >>>>using? Are you using integrated security? What version of SQL Server?
                    >>>>Without more information no one will be able to help you.
                    >>>
                    >>>
                    >>Turn on all errors and display them to see what you're getting:
                    >>
                    >>ini_set('disp lay_errors', '1');
                    >>error_reporti ng(E_ALL);
                    >>
                    >>And phpinfo() will tell you if the mssql extensions are loaded in PHP.
                    >>
                    >>Just having SQL Server on the system isn't enough. You also have to
                    >>enable it in php.
                    >>
                    >>--
                    >>============= =====
                    >>Remove the "x" from my email address
                    >>Jerry Stuckle
                    >>JDS Computer Training Corp.
                    >>jstucklex@att global.net
                    >>============= =====
                    >
                    >
                    >
                    >
                    >
                    yea i think thats the problem because ive got this now, with errors
                    turned on:
                    >
                    start
                    Fatal error: Call to undefined function mssql_connect() in
                    /home/default/site/user/htdocs/testmssql.php on line 5
                    >
                    >
                    >
                    so basically i need to do extension=php_m ssql.dll in my php.ini?
                    >
                    Yes, if everything else is set up correctly that should do it.

                    It's also a good idea to check the settings in the [MSSQL] section of
                    your php.ini.

                    --
                    =============== ===
                    Remove the "x" from my email address
                    Jerry Stuckle
                    JDS Computer Training Corp.
                    jstucklex@attgl obal.net
                    =============== ===

                    Comment

                    Working...