Tag > php
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…
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 ‘firstname.lastname@example.org‘ it would bring back the CodeIgniter error.
An Error Was Encountered
The URI you submitted has disallowed characters.
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…
setcookie('CookieName', '', time()-3600);
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.
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.