Archive for the ‘php’ Category
GD extension required
I’ve tryed to use some GD functions in php. Locally everything is ok, I use xampp on Windows. But when I moved my site to the server I get this error:
PHP Fatal error: Uncaught exception ‘WideImage_Exception’ with message ‘WideImage requires the GD extension, but it’s apparently not loaded…
In my php app the WideImage library is used and it utilizes GD library. So, there isn’t GD extension installed. Well, let’s install it:
apt-get update apt-get upgrade --show-upgraded apt-get install php5-gd
After installing php5 gd library the error have been gone and WideImage classes begin to work properly.
New line to paragraph in PHP
Here’s an example of how to convert new line (LF – line feed, ‘\n’) or carriage return (CR, ‘\r’) followed by new line (CR+LF, ‘\r\n’) to <br> or <p>. In case of double or more breaks we’ll get a paragraph but in case of one break we’ll have <br>.
$text = 'Lorem ipsum\r\n\r\ndolor sit\r\namet.'; // double or more nl to <p> $text = preg_replace('/(\r?\n){2,}/', '</p><p>', $text); // nl to <br> $text = preg_replace('/(\r?\n)+/', '<br />', $text); echo '<p>' . $text . '</p>';
output: <p>Lorem ipsum</p><p>dolor sit<br />amet.</p>
How to execute additional SQL in After Execute family events in CCS
Hi! This article is about how to execute some addtitional SQL after the primary SQL in the CodeCharge Studio’s Record has been executed.
Very often I have to perform some additional manipulations with the database after the Record submission. In this article I want to share the approach I use to reach the desired result. If you use a different approach to reach the same result I’m waiting your comments!