Jump to content

Character limit on an echo?? **SOLVED**


Round

Recommended Posts

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 $comments
only 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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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 stuck

Thanks
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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 table

if 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 msg

but
[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?

Thanks

P.s where the variables 1&2 are being created are different because I was testing to see if both methods worked, and they do.
Link to comment
Share on other sites

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\" ";
to
sql = "select * from table where columnname ='variable' ";
and it worked fine.


cheers
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.