PHP newbie needs SQL Help

Discussion in 'PHP' started by crazeydazey, Nov 9, 2007.

  1. #1
    Hi all,

    I am currently a VB.net programmer, but decided as a bit of a challange I would write my website in PHP (and I've done very very little PHP before).

    I have also decided to use MSSQL (rather than MySQL, I think there is only so much new stuff you can try at once)..

    So here's my problem..

    I have a very simple database called test*, with one table - tbltest*, containing of feilds - testid* and testdescription*.

    in the table there are 2 rows

    testid | testdescription
    ------------------------
    1 | (a big load of text, about 500 chars)
    2 | (another big load of text about 500 chars)


    and I have a simple php page :-

    
    <?php
    $msconnect=mssql_connect("crazeydazey","user1","password");
    $msdb=mssql_select_db("test",$msconnect);
    $msquery = "select * from tbltest";
    $msresults= mssql_query($msquery);
    while ($row = mssql_fetch_array($msresults)) {
           echo "<p>" . $row['testid'] . " " . $row['testdescription'] . "</p>\n";
    }
    ?>
    
    PHP:
    when I run my code, the testdescription is getting truncated to 255 chars..

    I bet there is a really simple solution to this and I'm going to look like a right numpty :eek: , but could someone please put me out of my misery.

    many many thanks

    Daz..

    * the names have been changed to protect the inocent
     
    crazeydazey, Nov 9, 2007 IP
  2. Maloid

    Maloid Peon

    Messages:
    69
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Could you export your database structure and post it there so I could see how it looks like?
     
    Maloid, Nov 9, 2007 IP
  3. crazeydazey

    crazeydazey Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    not sure if this is what you mean, but....

    
    CREATE TABLE [dbo].[tbltest] (
    	[testid] [int] NOT NULL ,
    	[testdescription] [varchar] (1000) COLLATE Latin1_General_CI_AS NOT NULL 
    ) ON [PRIMARY]
    GO
    
    
    Code (markup):
     
    crazeydazey, Nov 9, 2007 IP
  4. crazeydazey

    crazeydazey Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Fixed it..:D

    it didn't seem to like varchar datatype

    changed it to text and it works fine...
     
    crazeydazey, Nov 9, 2007 IP