Rate this article

How do I replace characters in a field before updating

Rating: 0.0/5 (0 votes cast)

I need to strip out any question marks from a field before I insert/update the record.
The information in this specific field is used as a file-name with mod-rewrite to show friendly url's
Obviously a question-mark will break the url as php uses question-marks as uri parameters

You need to use a "Custom Trigger" of the "Before" kind

The code will be

$tNG->setColumnValue("art_heading", trim(str_replace('?',' ',$tNG->getColumnValue('art_heading'))));

Remember to use the escape character \ when you want to replace a " with a '

e.g. $tNG->setColumnValue("art_heading", trim(str_replace('"','\'',$tNG->getColumnValue('art_heading'))));

Adobe

Free PositiveSSL and WhoisGuard with Every Domain Purchase
ionCube Online PHP Encoder
XMS Systems

Although we try to ensure all the articles submitted are valid it is your responsibility to make sure you have backups before you use these suggestions on your pc or websites.
We do not take any responsibility for any data-loss, loss in functionality or any problem that might arise in what-ever way or form by making use of the information on this site.

"Friends of Interakt" has no connection to the Adobe Interakt Company