Round Posted December 8, 2006 Share Posted December 8, 2006 I am using echo($comments); to display a users comments on my web page but, it is cutting it short mid comment? E.g. A table has a column called comments. one row has "It is a wonderful day and I am looking forward to xmas" stored in its comments column.But when I query the db and pass this into the variable $comments, and then echo $commentsonly this displays on the page "It is a wonderful day and"Where is the rest of it??? Is there a limit to the amount echo will display??Cheers Quote Link to comment Share on other sites More sharing options...
Orio Posted December 8, 2006 Share Posted December 8, 2006 You probbly limited the place in your database. In what type of field do you store the text?Orio. Quote Link to comment Share on other sites More sharing options...
taith Posted December 8, 2006 Share Posted December 8, 2006 do you have a charlimit in the database? seems to set to 25, try changing it from varchar to text Quote Link to comment Share on other sites More sharing options...
Round Posted December 8, 2006 Author Share Posted December 8, 2006 The limit in the db is set to 3000 characters and I have checked the table and the whole sentence is in there??Its very strange Quote Link to comment Share on other sites More sharing options...
Orio Posted December 8, 2006 Share Posted December 8, 2006 Can you show us the script? (or at least the relevant part)Orio. Quote Link to comment Share on other sites More sharing options...
Round Posted December 8, 2006 Author Share Posted December 8, 2006 The sentence was just an example for explanation.Here is full script.[code]$num3 = mssql_num_rows ($rs3); if ($num3 !=0) { $row3 = mssql_fetch_array( $rs3 ); $totabs = $row3["totabs"]; $totatt = $row3["totatt"]; $totperc = (round(100 * ( $totatt / ( $totatt + $totabs ) ) ,1) ); } else { $totperc = 0; } $row = mssql_fetch_array( $rs ); $row2 = mssql_fetch_array( $rs2 ); $list = "<h3><b>Progress Review Number : </b>".$review_id."</h3>"; $list .= "<p><b>Review Title : </b>".$row2["review_title"]."</p>"; $list .= "<p><b>Date of Review : </b>".$row2["review_dt"]."</p>"; $list .= "<p><b>Name : </b>".$row["forename"]." ".$row["surname"]." (".$row["id_num"].")</p>"; $list .= "<table border=\"0\" align= \"center\" cellpadding=\"2\" width=\"100%\">"; $list .= "<tr>"; $list .= "<th class=table colspan=\"2\">Areas Discussed</th>"; $list .= "<th class=table colspan=\"2\">Discussion Summary</th>"; $list .= "</tr>"; $list .= "<tr>"; $list .= "<th class=table colspan=\"2\"><p>Work Outstanding</p>th>"; $list .= "<td class=tblleft colspan=\"2\">".$row2["coursework"]."</td>"; $list .= "</tr>"; $list .= "<tr>"; $list .= "<th class=table colspan=\"2\">Other Issues</th>"; $list .= "<td class=tblleft colspan=\"2\">".$row2["other_issues"]."</td>"; $list .= "</tr>"; $list .= "<tr>"; $list .= "<th class=table colspan=\"2\">Support</th>"; $list .= "<td class=tblleft colspan=\"2\">".$row2["support"]."</td>"; $list .= "</tr>"; $list .= "<tr>"; $list .= "<th class=table colspan=\"2\">Other Issues</th>"; $list .= "<td class=tblleft width=\"25%\">Average - ".$totperc."%"."</td>"; $list .= "<td class=tblleft width=\"25%\">Target - ".$row2["att_target"]."%</td>"; $list .= "</tr>"; $list .= "<tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr>"; $list .= "<tr>"; $list .= "<th class=table colspan=\"4\">Targets to be achieved</th>"; $list .= "</tr>"; $list .= "<tr>"; $list .= "<td class=table colspan=\"4\">".$row2["targets"]."</td>"; $list .= "</tr>"; $list .= "<tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr>"; $list .= "<tr>"; $list .= "<th class=table colspan=\"2\">Unit</th>"; $list .= "<th class=table>Previous Target</th>"; $list .= "<th class=table>New Target</th>"; $list .= "</tr>"; while ( $row4 = mssql_fetch_array( $rs4 ) ) { $list .= "<tr>"; $list .= "<th class=table colspan=\"2\">".$row4["course"]."</th>"; $list .= "<td class=tblleft>".$row4["prev_target"]."</td>"; $list .= "<td class=tblleft>".$row4["new_target"]."</td>"; $list .= "</tr>"; } $row5 = mssql_fetch_array( $rs5 ) ; $list .= "<tr>"; $list .= "<th class=table colspan=\"2\">Communication</th>"; $list .= "<td class=tblleft>".$row5["commmin"]."</td>"; $list .= "<td class=tblleft>".$row5["commpot"]."</td>"; $list .= "</tr>"; $list .= "<tr>"; $list .= "<th class=table colspan=\"2\">Application of Number</th>"; $list .= "<td class=tblleft>".$row5["appmin"]."</td>"; $list .= "<td class=tblleft>".$row5["apppot"]."</td>"; $list .= "</tr>"; $list .= "<tr>"; $list .= "<th class=table colspan=\"2\">Information Technology</th>"; $list .= "<td class=tblleft>".$row5["itmin"]."</td>"; $list .= "<td class=tblleft>".$row5["itpot"]."</td>"; $list .= "</tr>"; $comments .= $row2["comments"]; $list .= "</table>"; #list details echo( $list ."<br><h3>Tutor Comments</h3><h4>" .$comments); mssql_close ( $conn );[/code]I have some test data that is just blah 100 times, I have counted it and its only showing blah 51 times in each field Quote Link to comment Share on other sites More sharing options...
Round Posted December 8, 2006 Author Share Posted December 8, 2006 I have worked out that by returning blah 51 times equals 204 characters and the spaces between each blah equals 50. So its only returning a variable that is 254 characters long.Is the amount of characters retrieved from a db and stored in a variable limited?I have noticed it does this to all variables if they exceed this amount in the db.Any ideas? as I am stuckThanks Quote Link to comment Share on other sites More sharing options...
taith Posted December 9, 2006 Share Posted December 9, 2006 change the field in the database to a text field, that shouldnt have any limits on character lengths. Quote Link to comment Share on other sites More sharing options...
Round Posted December 12, 2006 Author Share Posted December 12, 2006 I've done all the suggestions, and it's still only retrieving the first 254 characters of the data stored in the db. ???I have also changed the mssql.textlimit and mssql.textsize in the php.ini file and that hasn't made any difference either.What else could it be??What does the mssql.batchsize in the php.ini file control?Many Thanks Quote Link to comment Share on other sites More sharing options...
TEENFRONT Posted December 12, 2006 Share Posted December 12, 2006 never known this problem.. is the field definatly TEXT, with no limitations? like varchar(255) ?i pull records with 1000's of characters, and dont get a limit problem. Quote Link to comment Share on other sites More sharing options...
Round Posted December 12, 2006 Author Share Posted December 12, 2006 The colimn is set to 2000.is it to do with the mssql_fetch_array? should I retrieve another way?or is it something to do with IIS?I'm really stuck on this one?!?Cheers Quote Link to comment Share on other sites More sharing options...
Round Posted December 12, 2006 Author Share Posted December 12, 2006 I understand what you mean by the text field now after a little research. I was reluctant to change the fields to text at first because it would only allow a maximum length of 16. This turns out to be 16 bytes, not characters and refers to a pointer. My next question is: the actual tables have a mixture of column datatypes set to varchar(2000) and varchar(3000), if I change all of these datatypes to text 16 will I loose any of the data that already exists in the database?(I cannot afford for this to happen)How many charaters can a text field hold?Many Thanks Quote Link to comment Share on other sites More sharing options...
TEENFRONT Posted December 12, 2006 Share Posted December 12, 2006 shouldnt loose any info from the database, as your only updating the type. Not sure how many a text field can hold, but you can always you longtext field type to be sure.** i think.. Quote Link to comment Share on other sites More sharing options...
Round Posted December 12, 2006 Author Share Posted December 12, 2006 The text field isn't an option because it will only allow 1022 characters, we have it set to 2000 on varchar, so its not enough. also we may want to increase the 2000 limit another day anyway.I have read I should connect to the db using odbc rather than $conn = @mssql_connect( "server", "username", "password" ) or die( "Err:conn"); $rs = @mssql_select_db( "dbname", $conn) or die( "ERR:Db");Is anyone familiar with this?Cheers Quote Link to comment Share on other sites More sharing options...
Round Posted December 13, 2006 Author Share Posted December 13, 2006 I have created an ODBC connection and it seems to work ok. I can connect to the db and display more than 255 characters.I have one problem it will only let me query the db with a very basic query e.g select * from tableif i try select * from table where columnname = 'whatever'I get an sql error???Here is my code:[code]#connect to db $conn = odbc_connect('DSNname','username','password'); if(!$conn) {exit("Err:Conn"); } #create query $sql = "select * from table where ID_num=\"6\" "; $result = odbc_exec($conn, $sql); if(!$result){exit("Err:SQL");} while($row = odbc_fetch_array($result)){ $variable1 = $row["coulumn1"]; $variable2 = odbc_result($result, "column2");echo($variable1 .$variable2);}[/code]= error msgbut[code]#connect to db $conn = odbc_connect('DSNname','username','password'); if(!$conn) {exit("Err:Conn"); } #create query $sql = "select * from table"; $result = odbc_exec($conn, $sql); if(!$result){exit("Err:SQL");} while($row = odbc_fetch_array($result)){ $variable1 = $row["coulumn1"]; $variable2 = odbc_result($result, "column2");echo($variable1 .$variable2);}[/code]Works fine??I have checked for case on column names just incase and its fine.any clues?ThanksP.s where the variables 1&2 are being created are different because I was testing to see if both methods worked, and they do. Quote Link to comment Share on other sites More sharing options...
Round Posted December 13, 2006 Author Share Posted December 13, 2006 I have solved it thank god!!all I had to do was replace the \" \" to ' ' within the query.eg sql = "select * from table where columnname =\"variable\" ";tosql = "select * from table where columnname ='variable' ";and it worked fine.cheers Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.