#1
  1. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,640
    Rep Power
    4476
    Hi. I just installed SQL Server 7.0 and I'm trying to write a simple PHP script to read some data out of the sample databases.

    I've fixed the php3.ini file, and that corrected the 'call to unsupported function' error I was getting.

    Now, it doesn't seem to connect to the server with the mssql_connect command. Here is my code (code begins on line 8):
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <?php

    $link_id = mssql_connect("JOHNHOLM","user1","pass1");
    //$link_id = mssql_connect('localhost','user1','pass1');

    $db = mssql_select_db("Northwind",$link_id);

    $query = mssql_query("SELECT * FROM Categories WHERE CategoryID = 1",$link_id);
    $result = mssql_fetch_array($query);

    echo "Category 1<hr>";
    echo "Category Name: " . $result['CategoryName'] . "<br>";
    echo "Description: " . $result['Description'] . "<br>";
    echo "Picture: " . $result['Picture'] . "<br>";
    echo "<hr>";

    ?>
    [/code]
    The SQL Server box says my server name is "JOHNHOLM"

    I've tried various combinations of localhost and JOHNHOLM, with single and double quotes.
    Here is the error I get if I just use JOHNHOLM
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    Warning: MS SQL message: ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier. (severity 16) in C:Inetpubwebpubtestdatabase.php3 on line 17

    Warning: MS SQL: Query failed in C:Inetpubwebpubtestdatabase.php3 on line 17

    Warning: 0 is not a MS SQL result index in C:Inetpubwebpubtestdatabase.php3 on line 18
    [/code]

    Here is the error I get if I just use localhost:
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    Warning: 0 is not a MS SQL link index in C:Inetpubwebpubtestdatabase.php3 on line 13

    Warning: 0 is not a MS SQL link index in C:Inetpubwebpubtestdatabase.php3 on line 15

    Warning: 0 is not a MS SQL result index in C:Inetpubwebpubtestdatabase.php3 on line 16
    [/code]

    I've added a login under the SQL Server Enterprise Manager, so the problem shouldn't be with the login and username, or is it? Is there difference b/t single and double quotes ?

    I've tried localhostJOHNHOLM, but that gives me the sames errors as just using localhost.

    If you know anything about this, please give me some pointers. I need to do a e-commerce page for a class i'm in and the instructor is very pro ASP, but i'd like to show everyone how easier it can be done in PHP. Only this is slowing me down...

    Thanks in advance...


    ---John Holmes
    ---www.SepodatiCreations.com
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    1
    Rep Power
    0
    it seems that the picture file which has type as "ntext" cause the problem.
    if you use other table ie. customers , it will work
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    63
    Rep Power
    15
    If John's suggestion doesn't work...

    check your php.ini file... did you uncomment that mssql extension?

    extension=php3_mssql.dll

Similar Threads

  1. PERL w/DBI connecting to MSSQL using iODBC & FreeTDS
    By dutchmasta in forum Perl Programming
    Replies: 2
    Last Post: January 20th, 2004, 12:11 AM
  2. Question: PHP, MSSQL, ODBC
    By rlorenzo in forum PHP Development
    Replies: 10
    Last Post: December 15th, 2003, 12:28 PM
  3. What's wrong on this code (connecting to MSSQL)
    By PWH in forum ASP Programming
    Replies: 1
    Last Post: March 8th, 2003, 03:40 AM
  4. insert unicode data into MSSQL 2000 via web forms
    By sunnychan in forum PHP Development
    Replies: 2
    Last Post: May 23rd, 2002, 12:51 PM
  5. connecting to a mssql database
    By TerryS999 in forum PHP Development
    Replies: 2
    Last Post: November 16th, 2000, 09:45 AM

IMN logo majestic logo threadwatch logo seochat tools logo