Posts in 'PHP'
SQLite, MySQL, PHP: Ternary operator (IF() statement) in MySQL and SQLite
Posted on 03. Feb, 2010 by Dragos.
While working on a proxy checker tool for one of my projects, I was struggling on how to execute a conditional query on my SQLite database to update a column only if its value is greater than 0 (it would be pointless in my case to let the script update the column with negative values). [...]
Continue Reading
PHP: How to download a webpage (aka web scrapping) with PHP
Posted on 03. Oct, 2009 by Dragos.
There are many ways of downloading web pages, or web content. Personally I like to use cURL for my web scrapping needs, but sometimes I also use fsockopen and file_get_contents. Here are 3 different functions that will allow you to download web content. cURL: function getData($url) { if($url!='localhost' && $url!='http://localhost') { $ch=curl_init(); curl_setopt($ch, CURLOPT_URL, $url); [...]
Continue Reading
WordPress: Best SEO iTranslator for WordPress, get free traffic from fully automated plugin script
Posted on 04. Sep, 2009 by Dragos.
I’ve just decided to publish my translation plugin for WordPress. It has helped me a lot to get free traffic, so I think other people might find it also useful. == Description == Best SEO iTranslator for WordPress is a translation plugin, fully automated, that will help you get new traffic and at the same [...]
Continue Reading
WordPress 2.8.4: Not ready to be installed with PHP 5.3 ?
Posted on 01. Sep, 2009 by Dragos.
I’ve just tried to install WordPress 2.8.4 on my testing machine (PHP 5.3). Right on the installation page a dozen of errors filled my screen, something like: Strict Standards: Declaration of Walker_Page::start_lvl() should be compatible with that of Walker::start_lvl() in /opt/lampp/htdocs/wordpress/wp-includes/classes.php on line 1214 This is not a big issue and it doesn’t interrupt the [...]
Continue Reading
PHP: How to get creation time of file with PHP on Linux machines
Posted on 01. Sep, 2009 by Dragos.
Unfortunately it is not possible to get the creation time of a file on Linux machines. None of the functions fileatime,filemtime or filctime will return the file creation time. Note: Note also that in some Unix texts the ctime of a file is referred to as being the creation time of the file. This is [...]
Continue Reading
PHP:ob_start() Display page at once, forget about cookie,headers sent too early errors
Posted on 21. Aug, 2009 by Dragos.
If you want to display your web pages at once, not subsequently, and reduce the “headers already sent, cannot send cookie information” errors, add ob_start() at the start of your script. This function will turn output buffering on. While output buffering is active no output is sent from the script (other than headers), instead the [...]
Continue Reading
PHP: Script to extract one’s contacts from email (Gmail, Yahoo,Hotmail,AOL…) and send invites – OpenInviter to go!
Posted on 18. Aug, 2009 by Dragos.
You’ll find many scripts to extract email contacts, but many of these are either commercial or just given as apis. For the last case, it’s good to extract contacts from an email using an external server, because that’ll help reduce the server load, but what if the website providing that service goes down? Not good. [...]
Continue Reading
Coding:How to fetch user profile data with SSI.php from a SMF forum database
Posted on 20. Jul, 2009 by Dragos.
Even though SMF offers a way to integrate their forum into any website, they do not provide enough information on how to do some basic tasks, e.g. fetching a member’s profile details from the database. Fortunately, Netbeans has a very helpful feature, the code Navigator which shows an instant preview of all functions available in [...]
Continue Reading
PHP Error: Call to a member function fetch_assoc() on a non-object in
Posted on 23. Jun, 2009 by Dragos.
If you get this error: Call to a member function fetch_assoc() on a non-object in … , it means that you have an error in your mysql syntax. Supposing that $mysqli is your database connection object, put echo $mysqli->error; just before the line you’re getting the error on. $mysqli=new mysqli(HOST,USER,PASS,DB); $mQuery=$mysqli->query('select `data` from `this_table` where [...]
Continue Reading
PHP: Get all files and folders from a directory (folder)
Posted on 16. Jun, 2009 by Dragos.
To get all files and folders from a directory (folder) I found scandir to be the perfect solution. scandir scans a directory and returns an array containing all files and directories under the parent directory we’re looking in. The code below will try to remove a directory, if the element is a directory or delete [...]


