ggalan
03-07-2012, 01:31 AM
i am trying to knock out the last comma from db record but getting errors
pretty straight forward, i thought
$query = "SELECT mycell FROM mytable WHERE id='1'";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
$str = $row[0];
//$str = trim( preg_replace(''', "/'/", $str ) );
$str = substr($str,'',-1);
echo $str . "\n";
error msg:
Warning: substr() expects parameter 2 to be long, string given in
and
Warning: preg_replace() [<a href='function.preg-replace'>function.preg-replace</a>]: No ending delimiter '&' found in
re: this fixed it
$str = substr($str,0,strlen($str)-1);
re: fixed the last one w/ this
$str = trim( preg_replace('/'/', "'", $str ) );
pretty straight forward, i thought
$query = "SELECT mycell FROM mytable WHERE id='1'";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
$str = $row[0];
//$str = trim( preg_replace(''', "/'/", $str ) );
$str = substr($str,'',-1);
echo $str . "\n";
error msg:
Warning: substr() expects parameter 2 to be long, string given in
and
Warning: preg_replace() [<a href='function.preg-replace'>function.preg-replace</a>]: No ending delimiter '&' found in
re: this fixed it
$str = substr($str,0,strlen($str)-1);
re: fixed the last one w/ this
$str = trim( preg_replace('/'/', "'", $str ) );