wordpress blog stats

Archive for the ‘PHP’ Category

Having problems in uploading the WordPress Themes, Plugins etc. in Ubuntu? Here’s a simple and easy solution:

Solution – The uploaded file could not be moved to /var/www/

Simply open the file php.ini file, existing in /etc folder. For me, it is in:

/etc/php5/apache2/php.ini

Now search for the variable upload_max_filesize and change its value from 2M to whatever the file size, you want to, for me, I changed it from:

upload_max_filesize = 2M

to

upload_max_filesize = 100M

After this, restart your Apache Server, through the following post:

Install PHP, MySQL and Apache (LAMP) on Ubuntu (Linux)

And your problem could have been resolved.

Ubuntu – Call to undefined function mssql_connect()

If you are facing the error Call to undefined function mssql_connect() in Ubuntu / Linux, then you have to simply install php5-sybase to make this problem resolved.

Simply goto:

System -> Administration -> Synaptic Package Manager

And find the package or software as “php5-sybase“ or php sybase

and install the MS SQL Server module for PHP.

After successful installation, restart your Apache Server with the following command in the terminal:

sudo /etc/init.d/apache2 restart

And the problem is solved.

Or

goto gnome-terminal, and write the following command:

sudo apt-get install php5-sybase

(if php5 is not the version you’re using, then find that version’s php sybase package and install it)

After successful installation, restart your Apache Server with the following command:

sudo /etc/init.d/apache2 restart

And the problem is solved.

Jqgrid PHP Grid Component

Found a good post of getting free Jqgrid, a PHP Grid Component, where you can easily edit and delete the tables for normal and simple tables, without writing complete code in all the files for editing, deleting etc. Check out the following link for more details and download free Jqgrid PHP Grid Component:

Jqgrid PHP Grid Component
http://azgtech.wordpress.com/2010/08/01/jqgrid-php-datagrid-component-free/

Ubuntu IDE, Linux PHP IDE

If you are looking for different Ubuntu IDE or Linux PHP IDE, then you have come to the right place.

Ubuntu IDE, Linux PHP IDE

If you are looking for free Ubuntu IDE or Ubuntu Integrated Development Environment, to make you do coding or programming in your Ubuntu, then I would prefer you to go through the following post, to make you download and install some different and good PHP IDEs for your Ubuntu. So far, I have found Geany as a good, light weight and free PHP Editor, which will make me feel good while programming.

Ubuntu PHP Editor

Following is the list of some good PHP Editors, which you can download and install easily:

Geany

gEdit

Komodo Edit

Quanta Plus

Bluefish

Aptana

NetBeans

Hope this will help you finding a good PHP Editor for your Ubuntu.

If you know some other good and free Ubuntu PHP Editors or IDEs, please mention in the comments here.

If you are seeing the folowing type of error:

Could not reliably determine the server’s fully qualified domain name
or
Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName

while restarting your Apache Server through the following command:

sudo /etc/init.d/apache2 restart

then I have a better solution for you, which might let you resolve this error.

How To Resolve

Goto your apache folder, which would be:

/etc/apache2/

And open or create the following file

httpd.conf

After creating / opening the file, simply add the following line in the file:

ServerName localhost

Now save the file and restart your Apache Server by the following command:

sudo /etc/init.d/apache2 restart

And your error could have been resolved.

Hope this simple solution works for you in getting rid of the error:

Could not reliably determine the server’s fully qualified domain name
or
Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName

For some of the other PHP errors, you can follow the PHP Category:
http://www.webtechquery.com/index.php/category/php/

Also find out How To Install LAMP On Ubuntu:
http://www.webtechquery.com/index.php/2010/01/install-php-mysql-and-apache-lamp-on-ubuntu-linux/

If you are getting the error:

Your PHP installation appears to be missing the MySQL extension
or
Your PHP installation appears to be missing the MySQL extension which is required by WordPress

while installing WordPress or some other API  on your Ubuntu (Linux) machine, then there might be possibility that you have not installed the php-mysql package.

As now, PHP5 is the latest version, so you have to follow the steps below:

simply goto the Terminal (gnome-terminal) through:

Applications -> Accessories -> Terminal

and write the following command:

sudo apt-get install php5-mysql

and restart your apache server by the following command:

sudo /etc/init.d/apache2 restart

If you want to install LAMP on your system using Ubuntu, then the following post can help you:
http://www.webtechquery.com/index.php/2010/01/install-php-mysql-and-apache-lamp-on-ubuntu-linux/

Displaying Errors ON is a good way of dealing with the errors, warning etc., but only when you are running your code on Testing Environment aka Development Environment. But when you are running your code on Live Environment, then it is not suitable to make your errors, warnings, notices etc. ON. As it would make bad impact on the visitors of your website.

How to Display Errors ON for Windows

If you are a Windows user, then you have to modify the php.ini file.

Goto your wamp folder, which would be like:

D:\wamp\bin\apache\apache2.2.6\bin\

And open the file

php.ini

If you are unbable to find the folder or file as mentioned above, or if you are using some other server in Windows, then simply find the php.ini file located under apache folder (and not php folder), and open it in a text editor.

Find the text

display_errors = Off

and replace the text with:

display_errors = On

Save the file, and restart your Apache Server. And the problem is solved.

How to Display Errors ON for Linux (Ubuntu)

If you are a Ubuntu or Linux user, then you have to modify the php.ini file.

Goto your apache folder, which would be like:

/etc/php5/apache2/

And open the file

php.ini

If you are unbable to find the folder or file as mentioned above, then simply find the php.ini file located under apache folder, and open it in a text editor.

Find the text

display_errors = Off

and replace the text with:

display_errors = On

After saving the file, restart your Apache Server with the following command:

sudo /etc/init.d/apache2 restart

And the problem is solved.

If you are getting the following error while browsing any website in Windows or Linux (Ubuntu) like:

Fatal error: Call to undefined function curl_init()

then here is a simple and easy solution, for both Windows and Linux (Ubuntu) users.

For Windows

If you are having the error Call to undefined function curl_init() in Windows, then you have to simply modify a line in apache’s php.ini file.

Goto your wamp folder, which would be like:

D:\wamp\bin\apache\apache2.2.6\bin\

And open the file

php.ini

If you are unbable to find the folder of file as mentioned above, or if you are using some other server in Windows, then simply find the php.ini file located under apache folder (and not php folder), and open it in a text editor.

Find the text

extension=php_curl.dll

and remove the semi-colon at the start.

Now that line would look like:

extension=php_curl.dll

(without semi-colon on start)

Save the file, and restart your Apache Server. And the problem is solved.

For Ubuntu (Linux)

If you are having the error Call to undefined function curl_init() in Ubuntu or Linux, then you have to simply install php5-curl to make this problem resolved.

Simply goto:

System -> Administration -> Synaptic Package Manager

And find the package or software as “php5-curl“ or php curl

and install the CURL module for PHP. After successful installation, restart your Apache Server with the following command:

sudo /etc/init.d/apache2 restart

And the problem is solved.

Or

Or goto gnome-terminal, and write the following command:

sudo apt-get install php5-curl

(if php5 is not the latest php version, then find the latest php curl package and install it)

After successful installation, restart your Apache Server with the following command:

sudo /etc/init.d/apache2 restart

And the problem is solved.

PHP Tweets for Twitter

If you want to tweet on your twitter account through your website, using PHP, then you have come to the right place.

Auto Tweets Through Websites or Blogs

If you want your website’s users comments to be tweeted on twitter automatically, or any other web activity related to posts, comments etc., then you can simply embed the following code on your website, which will be called right after your desired activity, which you want to be posted on twitter.

PHP Auto Tweets

$twitter_username = 'your_twitter_username';
$twitter_pwd = 'your_twitter_password';
$msg = "Testing Tweet from PHP by http://www.webtechquery.com";
	if ($msg) {
		$twitter_url = 'http://www.twitter.com/statuses/update.xml';

		$curl = curl_init();
		curl_setopt($curl, CURLOPT_URL, "$twitter_url");
		curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($curl, CURLOPT_POST, 1);
		curl_setopt($curl, CURLOPT_POSTFIELDS, "status=$msg");
		curl_setopt($curl, CURLOPT_USERPWD, "$twitter_username:$twitter_pwd");

		$result = curl_exec($curl);
		$resultArray = curl_getinfo($curl);

		if ($resultArray['http_code'] == 200) {
			return true;
		} else {
			return false;
		}

		curl_close($curl);
	}

In the code, simply replace your_twitter_username and your_twitter_password with your twitter account’s username and password, and change the text of message Testing Tweet from PHP by http://www.webtechquery.com with your tweet message i.e. users comments, posts or anything else you want. After successful integration of this code with your website, you will be able to see your auto tweets on twitter.