Tag > php

24 Nov
2013

php icon grafxflow

PHP convert stdClass() object into JSON data

I was recently working on a website were the PHP function was doing a var_dump of the array and making it into a stdClass. The problem that I had was that there was also some jQuery code that needed to validate the data had been retrieved successfully. So the stdClass object needed to be converted to JSON data.

Here is how…

Continue reading…


27 Jul
2013

codeigniter icon grafxflow

Pass email in CodeIgniter url with jQuery and php

Here is the problem:

I was working with CodeIgniter and created a search form which passed its search terms via jQuery to the url like http://www.url.com/search/search_terms/, then the php would search the database and bring back the results. So what was the big issue you may think? Well if somebody tried to search for an email ‘anybody@email.com‘ it would bring back the CodeIgniter error.

An Error Was Encountered
The URI you submitted has disallowed characters.

CodeIgniter An Error Was Encountered

Continue reading…

Posted in: <CodeIgniter>

25 Jul
2013

php icon grafxflow

Reset cookies expiry date is not working in php

While recently working on a website I was trying to unset a cookie by resetting its expiry date back an hour using setcookie. But for some reason it would not work. Here is the code I was trying…

Continue reading…

Tagged: < | | | | | | >

18 Mar
2013

google analytics icon grafxflow

Hide google analytics on preview posts/pages

In WordPress you may have added (by hand) your google analytics to the footer.php file. But this brings a problem that you may not have noticed. While previewing a post/page your are still telling google to analyse this page even though it is not live. So the code needs to be hidden.

The preview URL will look something like this www.yourwebsite.co.uk/?p=1234&preview=true.

Continue reading…

Posted in: <WordPress>

18 Mar
2013

wordpress icon grafxflow

Add widget to header in WordPress

You may want to add a widget to your WordPress theme header (or any page template) but have noticed that it doesn’t appear in admin (Appearance->Widgets). Luckily it’s possible with the following PHP code which makes it appear in admin and on your website page. The code is also based on a custom/from scratch theme.

Continue reading…

Posted in: <WordPress>

smart search