Whats wrong with the connection between php and ms sql server ?

Discussion in 'Databases' started by adnap, Aug 7, 2009.

  1. #1
    The php cant seems to connect with the server. There is no respond when i run it. Wonder what went wrong? Did i miss out installing something or ?
    Have used these codes below:

    <?php
    $conn=mssql_connect('server', 'username', 'password');
    $db=mssql_select_db("database",$conn);
    if (!$conn || !$db ) {
    die ('cannot connect properly')
    }
    $query="SELECT companyName FROM Customers;";
    $result= mssql_query($query);
    while ($row=mssql_fetch_array($result)){
    echo $row['number']."<br>\n";}
    mssql_close($conn);
    ?>

    Can someone help? thanks alot.
     
    adnap, Aug 7, 2009 IP
  2. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you're doing echo $row['number'] whilst you should be doing echo $row['companyName'];
     
    premiumscripts, Aug 7, 2009 IP
  3. adnap

    adnap Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    sorry. typo error.
    i did echo $row['companyName']..
    but still it doesnt seems to run, still blank page, nothing appears.

    Whereas if i echo "aaaa" BEFORE the connection strings start, the "aaaa" did appear. But when its put AFTER the connection strings, nothing appears.

    Wonder whats happening?
     
    adnap, Aug 10, 2009 IP
  4. AirForce1

    AirForce1 Peon

    Messages:
    1,325
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Nothing appears. It seems weird. If anything go wrong, you would get the return 'cannot connect properly' for you have die() there. ;)
    I think you must open the debug mode in your environment.
     
    AirForce1, Aug 10, 2009 IP
  5. adnap

    adnap Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    ya its wierd that the error msg didnt even appear. how to go about opening the debug mode ? any idea whats going on here ? is there anything that i need to install or edit in the extensions, to solve this problem ?
     
    adnap, Aug 10, 2009 IP