Forum Moderators: coopster

Message Too Old, No Replies

Truncation on read from Database

         

Phobia1

4:47 pm on Nov 29, 2008 (gmt 0)

10+ Year Member



Hi
Could anyone help me fix this annoying problem please.
I can put data into my mysql database. However when I run a page that reads the data into form, the data is truncated to just one word. Brown cow, just display as Brown for instance. If I change the data and update all is ok, but when I read it back, truncated. Here is the page in question.
Thanks in advance and greetings from Bulgaria
Fred.
//modify.php
<php
require("common.php") ;
if (!($row = mysql_fetch_object($result))){
DisplayErrMsg("Internal error: the entry does not exist") ;
exit() ;
}

$resultEntry['Ref']=$row->Ref;
$resultEntry['Broker']=$row->Broker;
$resultEntry['Brokerphone']=$row->Brokerphone;
$resultEntry['Brokeremail']=$row->Brokeremail;
$resultEntry['Comments'] =$row->Comments;

GenerateHTMLForm2( $resultEntry, "update.php?rowid=$detail", "MODIFY" );

mysql_free_result($result) ;
?>

//common.php
function GenerateHTMLForm2($formValues, $actionScript, $submitLabel ) {

printf("<FORM METHOD=post ACTION=\"%s\"><PRE>\n", $actionScript);

printf("<TABLE border=\"0\" width=\"100%%\">");

printf("<TD align=right><B>Our Reference:</B></TD><TD><INPUT TYPE=Text SIZE=10 NAME=Ref Value=".$formValues['Ref']."></TD></TR>");
printf("<TD align=right><B>Broker:</B></TD><TD><INPUT TYPE=Text SIZE=30 NAME=Broker Value=".$formValues['Broker']."></TD></TR>");
printf("<TD align=right><B>Broker phone no.:</B></TD><TD><INPUT TYPE=Text SIZE=30 NAME=Brokerphone Value=".$formValues['Brokerphone']."></TD></TR>");
printf("<TD align=right><B>Broker email:</B></TD><TD><INPUT TYPE=Text SIZE=30 NAME=Brokeremail Value=".$formValues['Brokeremail']."></TD></TR>");
printf("<TD align=right><B>Comments:</B></TD><TD><INPUT TYPE=Text SIZE=50 NAME=Ref Value=".$formValues['Comments']."></TD></TR>");
printf("</TABLE>");

printf("<INPUT TYPE=submit name=\"submit\" VALUE=\"%s\">", $submitLabel );

printf("</PRE></FORM>" );

}

//update.php
this works just fine

coopster

9:59 pm on Dec 1, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



If you view the source, is the information complete? For example, is the value "Brown Cow" in the source, or just the truncated "Brown" version? I'm guessing your GenerateHTMLForm2 process needs to use htmlentities [php.net] during output.

vincevincevince

10:52 am on Dec 2, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Missing " symbol problem!

You have:

Value=".$formValues['Ref'].">

Should be:

Value=\"".$formValues['Ref']."\">

The " you have there 'disappears' as it is used to terminate the string you started by writing " after printf( - you must put an escaped " (\") in as well so that it 'survives' output. This is the case for all your Value= instances.

Phobia1

4:02 pm on Dec 2, 2008 (gmt 0)

10+ Year Member



I am soooooooooo grateful for the answer from super Vince.
Thanks once again.
Arrrgggh syntax
F