Hi I have table for "comments" , here it has a field called "comment_text" , I insert the comment like this to table
$query="insert into `comments`
(`id`,
`comment_text`,
`date`)
values
('',
'".sprintf("%-70s",mysql_real_escape_string(ucwords(trim($strTitle63_5))))."',
'$date')";
As you can see i am setting the comment length to fix 70 characters (always the original comment is less than 70 characters.)
Everything works fine unless i insert a value with quote , if i insert a comment with a quote , in the database table i can see only 69 characters .
Example :
I insert these two comments
Comment 1 : "Flat Rate Overlaps With Another Flat Rate Code"
Comment 2 : "Claim Details Don't Match BSI/BRI Guidelines"
later when i try to check the string length . Comment 1 is 70 and Comment 2 is 69. Is there any reason for this ?
Every comment that has a quote gives me this issue . :( .
Thanks in advance .
UPDATE
My code
Model
function get_coc5_comment_details()
{
$this->db->select("comment_text");
$this->db->from("comments");
$result=$this->db->get();
return $result->result_array();
}
Controller
function validate_db()
{
$result = $this->invoice_model->get_comment_details();
$this->load->view("comment_details_view",array("result"=>$result));
}
view
foreach ($result as $row)
{
$comment = $row['comment_text'];
echo strlen($comment)."<br>";
}