whats wrong with this code

Discussion in 'PHP' started by onlyican.com, Jan 11, 2006.

  1. #1
    Hey

    I know how to connect to a MySQL DB

    But i NEED to connect to a MSSQL db on another server.

    This is what I am using

    $db = mssql_connect("host", "username", "password");

    mssql_select_db ("table", $db);

    $query = "select top 10 *
    from vw_Developments";

    $result = mssql_query($query);


    while ($row = mssql_fetch_assoc($result)) {


    But I am getting this error
    Fatal error: Call to undefined function: mssql_connect() in /home/***/public_html/***/word/test7.php on line 18

    Line 18 is $db = mssql_connect....

    Can anyone help
     
    onlyican.com, Jan 11, 2006 IP
  2. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Is your server firewall configured to allow a connection to a remote server?
     
    dave487, Jan 11, 2006 IP
  3. onlyican.com

    onlyican.com Peon

    Messages:
    206
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I have checked with them

    They said I should be able to connect to another hosts db

    the other hosts has said that I should be able to connect with them
     
    onlyican.com, Jan 11, 2006 IP
  4. tflight

    tflight Peon

    Messages:
    617
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The clue is in the error message, "call to undefined function". This means your copy of PHP doesn't include the necessary extensions to use the mssql_connect function. Basically it doesn't "know" that function. You can double check this with the following:
    <?php
    if (function_exists('mssql_connect')) {
       echo "mssql functions are available in this copy of PHP.<br />\n";
    } else {
       echo "mssql functions are not available in this copy of PHP.<br />\n";
    }
    ?>
    PHP:
     
    tflight, Jan 11, 2006 IP
  5. onlyican.com

    onlyican.com Peon

    Messages:
    206
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I am currently fighting with my hosting company (again)

    They say it is nothing to do with them

    According to the PHP INfo and that script.

    my version of php is not working with MSSQL

    I think they are getting confused between MySQL and MSSQL

    Each time they say that they are right, and I argue it, I always win.
     
    onlyican.com, Jan 11, 2006 IP
  6. TMan

    TMan Peon

    Messages:
    126
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #6
    If the above script and phpinfo say you are right, than you are :D
     
    TMan, Jan 11, 2006 IP
  7. onlyican.com

    onlyican.com Peon

    Messages:
    206
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #7
    After 10 emails we got an answer.

    "Unfortunatly we do not support MS SQL on our servers"

    mmmmm.........

    OK

    So i started talking on ICP or ICQ something like that

    And they wont do anything, it is against there policy

    So far, these are against there policy, (bare in mind i have only been with them since november)

    It is against there policy to -;
    Update PHP
    Install PDFLIB
    Add a couple of lines to php.ini to accept code for mssql, not run mssql, just so i can access a remote server holding MSSQL.

    I like this hosting company......
     
    onlyican.com, Jan 11, 2006 IP
  8. stuw

    stuw Peon

    Messages:
    702
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #8
    name and shame...
     
    stuw, Jan 11, 2006 IP
  9. onlyican.com

    onlyican.com Peon

    Messages:
    206
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #9
    onlyican.com, Jan 11, 2006 IP
  10. onlyican.com

    onlyican.com Peon

    Messages:
    206
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Please note, for legal reasons.

    All i have stated is TRUE. This does not class and bad mouthing the company.
    It just lets people know that if they want a simple package, ok
    If they want more, and we all want more, then that is my experiance.
    I have not once said to not use them.
    (unless that counts)
     
    onlyican.com, Jan 11, 2006 IP
  11. tflight

    tflight Peon

    Messages:
    617
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Your host is just looking out for the overall well-being of their servers. Installing new extensions into PHP isn't something to be taken lightly when the server likely hosts hundreds of other websites. There is lots to consider like security issues with the extension, conflicts with other extensions, how it might impact overall server performance, etc.

    While installing things can sometimes be as simple as changing one line of code, the ramifications can be much more severe.

    As someone who provides hosting services, here is how I would deal with it if one of my clients asked for MSSQL. First I would check to see if there was a way around it without reconfiguring PHP, like using PEAR or something. If that didn't work then I would look at things like the security history of the extension, any server performance issues to consider, and if there are any known conflicts with currently running extensions or programs.

    If all looked good then I would roll out that extension on the next NEW server I brought online. I wouldn't add it to an existing server initially. Add clients to the new server and make sure there are no other, unforeseen problems. If things still went well then I would consider installing the extension on other existing servers as they had scheduled downtime.

    All of that could take time, however it is done to protect the integrity of the current setup. I may even loose that client because of the delay, but that is okay because if I blindly installed the extension and it caused a conflict I could loose hundreds of clients. In this case I too would say no. Since I don't run SQL Server having a client desire MSSQL support within PHP would be extremely rare.

    I hope this doesn't sound like a mean analogy, but you are sort of walking into McDonalds and asking for pasta. It just isn't on their menu. They might have the skills and capability to make it, but it just isn't on their menu. Especially since your host doesn't have SQL Server on their servers installing MSSQL extensions wouldn't be often considered.
     
    tflight, Jan 11, 2006 IP
  12. onlyican.com

    onlyican.com Peon

    Messages:
    206
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Macdonalds do pasta.

    Anyway..

    IF they said, we can not set you up for using MSSQL now, but we can look at id further down the line, then OK.

    But having to argue with staff members saying that it is down to the other host, or my codes, when it was down the them not having it set up pissed me off.

    Also

    Lypha meant to specialise in PHP and MySQL, they should have an option on a server for people to move to have the latest version of PHP, come on 4.3.1.

    They also offer 24hour chat help, more like ask a question and take 24 hour for a responce

    I am still waiting for a responce from 5 hours ago.
     
    onlyican.com, Jan 11, 2006 IP
  13. tflight

    tflight Peon

    Messages:
    617
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #13
    All perfectly valid points! Although I've never been to a McDonalds that served pasta! :)
     
    tflight, Jan 11, 2006 IP
  14. onlyican.com

    onlyican.com Peon

    Messages:
    206
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #14
    In the UK, I think they do here in spain, don't know, can't remember the last time i had fast food. (In spain, macdonalds, really really is like car tyres)

    ANyway, whats that got to do with PHP.

    Lol
     
    onlyican.com, Jan 11, 2006 IP
  15. onlyican.com

    onlyican.com Peon

    Messages:
    206
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #15
    So how much do you charge for hosting then tflight
    Whats your url
     
    onlyican.com, Jan 11, 2006 IP
  16. l234244

    l234244 Peon

    Messages:
    1,225
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Hit them where it hurts most, change hosts.
     
    l234244, Jan 11, 2006 IP
  17. tflight

    tflight Peon

    Messages:
    617
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #17
    I don't really advertise I offer hosting. I have a few servers running to support existing clients, but none of them have MSSQL support now.
     
    tflight, Jan 11, 2006 IP