Today while working on a clients site trying to fix w3 validation errors I found this interesting error when urlencode was’t able to encode/escape the space character in the title of the post. Scenario (urlencode not working for space character in php): The w3 validator error said: Line 142, Column 297: Bad value http://twitter.com/home?status=10 Ways […]
Category: PHP & Mysql
Remove » from WordPress title tag
First an intro to what this character is and where it comes in from before removing it from WordPress post title tag. The character “»” is: “»” that WordPress places by default before the title of any single post or page of your WordPress blog. In this post we will discuss ways to remove it […]
[Solved]How to create a HTML table from PHP array
While working on a project last week I encountered a situation in which an array was supposed to be converted to a HTML table. Basically I was working on a WordPress plugin and required the array to be dynamic with any number of items and keys in it so hard coding the table structure was […]
Simple AJAX post() function
This is a simple post function of AJAX using jquery. It will submit the data as POST to the specified php file and the data can then be worked normally as $_POST. $(“button”).click(function(){ $.post(“submit_to.php”, { name:”Nabtron”, description:”technology” }, function(data,status){ alert(“Data: ” + data + “\nStatus: ” + status); }); }); You can change the name […]
beforeSend for .post in AJAX
beforesend is really useful when you need to show some spinner while the data is being submitted and the response from the server is awaited. However I found it hard to find any set protocol to do that for .post function for AJAX in jQuery. This beforesend function does work for AJAX protocol but not […]
PHP mail function (for sending $_POST or $_GET data from form or AJAX)
This post is to give an example of simple PHP mail function. The first one is a simple mail function with minimum elements in it. The second one is a theme for sending $_POST posted data via email. <?php $email_to=”[email protected]”; $email_subject=”the posted variables”; $email_message=”Theinitial message”; $headers = “From: Beacze\r\n”. “Reply-To: [email protected]\r\n’” . “X-Mailer: PHP/” […]
[Solved] #1063 – Incorrect column specifier for column . . .
While adding auto increment value to one of the columns in my mysql database table, I got the error saying: Error SQL query: ALTER TABLE `tablename` ADD `id` VARCHAR(11) NOT NULL AUTO_INCREMENT AFTER `userid`, ADD PRIMARY KEY (`id`) ; MySQL said: #1063 – Incorrect column specifier for column ‘id’ Solution The error can easily be […]
[Solved]How to get content of page using PHP cURL – simple
This tutorial explains how to get the content of a page using PHP cURL. This is a perfectly working example, you just need to change the “url” value which can be either entered by hand there or made dynamic variable if it “GET” or “POST” the value from the submitted data to that page. The […]
[Solved]403 error when submitting “http://www” via GET even after urlencode
This weekend I’ve been working with a script which required me to send data via GET to another webpage coded in PHP to process it and then convert it into pdf format using dompdf. However, it was quite frustrating how it wasn’t doing what I expected it to and everytime the variable was passed it resulted […]
Define string without single or double quote in PHP
PHP allows you to define variables / strings specially in your scripts. The most commonly used methods for defining the variable in php are single quote ‘ or double quote “ However, there is a third way of defining the strings value in PHP too, which is not so commonly used, Its EOD. EOD is […]