Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Saturday, 24 August 2013

How to change the root password for MySQL in XAMPP?

By default, when you install XAMPP in your windows machine, the root password for the MySQL is set to empty. But this is not recommended, as the MySQL database without a password will be accessible to everyone. To avoid this, a proper/secure password must be set to the user root. To do it in XAMPP, there are two ways.

Method 1: reset XAMPP MySQL root password through web interface:

After you started your XAMPP server, go to the browser and type the URL http://localhost/security/ (incase you've modified XAMPP server port, you need to include that port number also in previous URL). The security page will be shown where you can change the root password for MySQL. This will update the phpMyAdmin config also.

Method 2: reset XAMPP MySQL root password through SQL update:


  1. Start the Apache Server and MySQL instances from the XAMPP control panel.
  2. After the server started, open any web browser and give http://localhost:8090/phpmyadmin/ (if you are running XAMPP on 8090 port). This will open the phpMyAdmin interface. Using this interface we can manager the MySQL server from the web browser.
  3. In the phpMyAdmin window, select SQL tab from the right panel. This will open the SQL tab where we can run the SQL queries.
  4. Now type the following query in the textarea and click Go
    UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root'; FLUSH PRIVILEGES;
  5. Now you will see a message saying that the query has been executed successfully.
  6. If you refresh the page, you will be getting a error message. This is because the phpMyAdmin configuration file is not aware of our newly set root passoword. To do this we have to modify the phpMyAdmin config file.
  7. Open the file [XAMPP Installation Path] / phpmyadmin / config.inc.php in your favorite text editor.
  8. Search for the string $cfg\['Servers'\]\[$i\]['password'] = ''; and change it to like this, $cfg\['Servers'\]\[$i\]['password'] = 'password'; Here the 'password' is what we set to the root user using the SQL query.
  9. Now all set to go. Save the config.inc.php file and restart the XAMPP server. 

Wednesday, 12 December 2012

How to Easily integrate PHP Code in Blogger or blogspot

PHP is considered as the most powerful computer language that makes things happen with the glimpse of seconds. However, PHP is not supported by Blogger or BlogSpot running platform which makes it extremely difficult to customize and implement some new latest developments, but there are still some ways through which you can add PHP codes in your Blogger enabled Website. Though, the results are not 100%, but it is far better than not having a PHP code on your blogger site. In this article, we will show you how to add PHP codes in Blogger.

Step#1: Creating a PHP File:

Before you can add PHP Codes in blogger, you have to first create a PHP file in which you have to use all the PHP codes that you would like to use.  However, make sure that the file is free from errors otherwise things would not look good. Following is the simple Hello World PHP code example, just for a basic guideline for some beginners

<?php
echo '<p>Hello World</p>';
 ?>

After creating the file with all your desired codes make sure you save it in .PHP extension. For example, mybloggerlab.php, you can use NotePad++ for writing codes because it is the only FREE standard developing tool.

Step#2: Hosting a PHP File:

Since, blogger does not allow you to host any kind of files like PHP, HTML or CSS. Therefore, you have to either host it on your hosting (if you have) or you can use Google Drive to host them for FREE. We have already written a detailed tutorial on It, so read it here.

You can also use Dropbox, and many other free hosting services but certainly they are not better than the features and reliability of Google Drive.

Step#3: Adding  PHP Codes in Blogger

After creating and hosting the PHP file, login into your Blogger account. Once logged in, head over to the dashboard and select the blog on which you would like to add PHP Codes. Now it depends on your needs whether you want to add the PHP code in posts, pages, sidebar or footer. Just paste the following code anywhere you would like to display the PHP file.

<object width="400" height="300" type="text/html" data=" your-file.php"></object>

Don’t forget to replace your-file.php with the URL of your own PHP file that you may have got while hosting it on services like Google Drive Dropbox and etc.

Congratulations: You have successfully added PHP codes to blogger. Go and check your blog to see if things are working as planned. Let us know, if you have a better way of doing this job.

We hope this tutorial has helped you in learning how to add PHP codes in blogger. Still, this is not the most accurate way because we are just using a iFrame technique to include the codes. Blogger needs to think more on making its platform friendly for the developers so that they can bring awesomeness to their blogs and websites.

Sunday, 12 February 2012

How to Host CSS or JavaScript Files in Blogger using Google Drive

Hosting CSS and JavaScript files on your Blogger blog has always been a matter of concern for a webmaster. People prefers to add their entire StyleSheet coding in one file, so they can upload it to their hosting and can easily apply it on their website.  Unfortunately, blogger has quite a few limitations that stop you from hosting CSS and JavaScript files. Recently our user sent us an email asking: is there any way to host files on blogger? What are the advantages of hosting CSS (StyleSheet) files?  Luckily, Google Drive provides you the opportunity to host CSS, JavaScript and HTML Files for FREE. In this article, we will show you How to Host CSS Files with Google Drive in Blogger?

Why to Host files on Google Drive?

  • Lots of Space: Google Drive provides you 5 GB storage to regular accounts so you can easily upload lots of documents. However, if your disk space is full, then you can upgrade your account from basic to premium. 
  • Create & collaborate: Google Drive provides you the flexibility to create and host different kinds of spreadsheets and presentations. Make some edits in the documents and see real-time changes as they appear. 
  • Reliable & Dependable: With 100% uptime, it provides you the freedom to host anything that you like. It has unlimited bandwidth, but you have to take care of your disk space it should not exceed 5GB mark or you can upgrade your account.
  • Go back and revise: Google drive tracks almost all the change that you make to your document - so whenever you will save a document, a new revision also gets save. You can take a glance back and can make revision accordingly. 
  • Share or make files Private: You can share your files and folders with anyone. Select whether others can comment, share, view or edit your stuff. You can handle everything instantly from your dashboard. 
  • Security at its best: Google Drive has always proven to be the most reliable free hosting service with unlimited bandwidth. Moreover, to provide full proof security Google drive has utilized HTTPS encryption to keep your documents secure.
  • All This For Free: All these impressive features for free.

What are the Advantages of Hosting CSS/JavaScript in one File?

Blogger doesn’t provide its users the flexibility to host CSS or JavaScript files in one separate link. They are hosted within the website’s coding through HTML Tags. 
For StyleSheet, <style> tag is use to define the style information for an HTML document.  Between two <style></style> tags, CSS coding is placed which specify how HTML elements should render in the web browser. Each HTML document can contain multiple <style> tags. 
For JavaScript <script> tag is use to define the script, such as JavaScript. The <script> tag either contains the scripting statements or it points to an external file through src attribute. Each HTML document can contain multiple <script> tags. 
Combining all StyleSheet/JavaScript coding in 1 file helps a website to load faster. Furthermore, it helps search engine to crawl your site smoothly. 

How to Host CSS Files with Google Drive in Blogger:

There are several third-party apps that could help you to host files in blogger including Google Apps, Google Code, and Google App bot. At MyBloggerLab, we use App bot, but the process of hosting files on Appbot is a lot complex. Google Drive is perfect and works better than Appbot because there is no need to worry about the bandwidth. 
Step#1: Copying CSS Coding From You Template:
To host your CSS file with Google Drive in Blogger, first thing you need to do is to copy your all StyleSheet coding from your template to an empty notepad. Go to Blogger » Your site » Template » Edit HTML » Proceed and search for the <b:skin><![CDATA[ tag. On finding this tag, you will see a large chunk of CSS coding, so copy all the CSS coding till the ]]></b:skin> tag.  For more details see the following screenshot.
Step#2: Preparing a style.css file
After copying the CSS coding, remove it from your template and paste the coding in an empty new notepad. Now save the document and name the file to style.css (the extension of the file should be in .css so the browser can render it as StyleSheet). For more details see the following screenshot.
Step#3: Hosting your style.css file on Google Drive:
The next thing is to upload style.css file to your Google Drive account. First go to Google Drive and login into your Gmail Account. Now you have to create a new folder, so you can upload all the web hosting files at one place. Press the “Create” button and from the drop down list select “Folder”. Now name the folder to anything that you like such as webhost, web files and etc. In the end, press "Create" to conclude.  
Now open the folders that you have created a few moments ago (right click on the folder name and select open). On selecting the upload icon present on the left side of your screen, a drop down list will appear which would provide you two choices i.e. File and Folder. Just select “File” and move to the next step.
Now it will request you to select the style.css documents that you created few moments a go. After selecting the file, press the open button and move to the next step.
On pressing the open button a small upload wizard would appear on the right side of your screen. It usually takes a minute or two to upload, but it entirely depends upon the size of your file and the speed of your internet connection.
Once uploading is done, press the “Share” button. Now you have to make this file available for public. Press change, and select “public on the web” so anyone on the Internet can find and access. Finally, press the Save button to conclude the wizard. For detailed instructions, check out the following screenshot.
Step#4: Getting a Proper Hosting Link
The second last step is to prepare a proper hosting link of your style.css file. Right click on the file that you uploaded few moments a go and select “Share”. Copy the whole URL present in the text area under “Link to share”. For more details see the following screenshot. 
After Copying the sharing Link from google drive, it would somewhat looks like this https://docs.google.com/file/d/your-file-code/. You have to change the copied link to https://googledrive.com/host/your-file-code. Remember: Make sure “your-file-code” remains the same before and after the changes are made. 
let us do a small demonstration which would help you in explaining better. For Example, if the link of my file is https://docs.google.com/file/d/0B0WJjcJEFNzibXRyZWlwNktKcFk/ so I will change it to https://googledrive.com/host/0B0WJjcJEFNzibXRyZWlwNktKcFk. The only thing which remains the same is the file code.
Step#5: Adding Google Drive Hosted CSS file in Blogger 
After preparing a proper hosting link of your file, once again go to Blogger » Your site » Template » Edit HTML » Proceed. Now search for the starting <head> tag and just above it paste the following code. Remember: Do not forget to replace https://googledrive.com/host/your-file-code with your Google drive hosting link, and make sure you have removed the CSS coding from the template as we have mentioned in the step#1. Once everything is done, press the “Save Template” button. 
<link href='https://googledrive.com/host/your-file-code' rel='stylesheet'/>

If you are still confused about the process then check out this in-depth video tutorial

Thursday, 22 July 2010

Using LightTPD with XAMPP on windows

I recently setup LighbetTPD on my machine because there is a need for me to use LightTPD server to achieve a video delivery with HTTP Pseudo-Streaming.  I decided to install it on windows since I use windows more often for development. The H264 streaming module works well on Apache but I am working more with the FLV streaming module which works well on LightTPD. I once tried installing mod_flvx.c on RH5 for Apache but it seems not to work well for me.

I had to dive into LightTPD and I think it’s a great decision. Prior to the installation of LightTPD on windows, I use the Apache on XAMPP as my web server. So, I will like to show you how I use the PHP (and MySQL – this will work well anyway, as far as the service is running) in XAMPP for LightTPD. You may be thinking; “why would you wanna do that since there is a WLMP webserver package that has all in one?”. Well the answer is: “I want to keep my Apache server and I don’t want to have two MySQL server or have two instance of php.ini file”. So follow this simple steps:

Firstly, download the Win32 version of LightTPD from the WLMP Project; I prefer using the win32 version, you can use the .zip one if you want to.

Double-click on the downloaded file to install LightTPD on windows. By default, the installation directory is “C:\Program Files\LightTPD” but I mine was installed in D:\LightTPD since my XAMPP is in the same D:\ drive.

After completing the installation, you will need to start the server by going to the LightTPD directory and look for the file ‘TestMode.bat’. Double click on it to start the server; a console window opens to indicate the server has started successfully. If you have port 80 in use, you will come across an error saying: can’t bind to port: 80 Address already in use. The default server.port on LightTPD is 80. Since my Apache is runing on port 80, I will have to modify the lighttpd-inc.conf file for LightTPD to work with an alternative port like 81 or 8080.

Open [LightTPD-Directory]\conf\lighttpd-inc.conf, remove the comment for server.port = 80 and modify the value to whatever port you want to use; as far as it’s not in use. Mine is server.port = 81. Save and run the ‘TestMode.bat’ again. If everything is set properly, the server will start.

Navigate or point your browser to http://localhost/ or http://127.0.0.1/ to see if LightTPD server is working.

Now you will have to configure the lighttpd-inc.conf to work with PHP. The PHP I used is actually that of XAMPP as I mentioned earlier. So modify cgi.assign value to “.php” => “D:\xampp\php\php-cgi.exe” [D:\xampp\ should be your XAMPP installation directory]

Modify other necessary lines you will/might need.

mod_flv_streaming is need (by me)
mod_rewrite is so need ( by me )
and so on.

To avoid the cygwin warning seen earlier, set the server.document-root value to have a forward slashes without the D: or C: as in “/Inetpub/wwwroot/”

After all modification, save the file; press Ctl+C on the console window to shutdown the server and re-launch, i.e double-click on ‘TestMode.bat’ to start the server again. You can also set LightTPD to run as a service. Open [LightTPD-Directory]\bin\ and double-click on Service-Install.exe to install the service.

You are set and good to go. To test if PHP is working, create a .php file with this content

1   <?php phpinfo(); ?>

Place the file in the htdocs directory, mine is D:\Inetpub\wwwroot\ and navigate to the URL, i.e http://127.0.0.1/info.php. You should be able to see the standard phpinfo() details.

That’s it!

I hope you’ll get this if you want to install LightTPD this way. Thanks for reading and please leave a comment to let me know how far it goes.

Wednesday, 24 February 2010

PHP vs ASP.NET - A Feature List

Introduction

I do not want to call this as a comparison but a list of equivalent features. You can find a lot of links if you search on the internet regarding 'which is good and which is bad'. Here, I would like to give the same weightage to both technologies as both have its advantages and disadvantages.

Background

Well, I made this list when I was thinking about the right technology for one of my latest requirements. I wanted to make something for a presentation as a part of my Architecture Design job.

 

Here Goes the List...

The choice of technology is completely dependent on the requirements. The factors that influence the decision of choice are based on the following:

  • Complexity of Business logic
  • Density of contents
  • Expected number of Hits (if it is a website)
  • Budget
  • Size of project, etc.

There are multiple options available for many features. The major ones are listed which are our recommendations.

 

ASP.NET PHP Comments
Latest Stable Version 4 5.3.3 As of 19 Aug 2010
License MS EULA PHP License v3.01
Price ASP.NET - .NET Framework is free. So ASP.NET also free PHP – Free PHP can be installed on any OS and Web server. But ASP.NET is recommended for IIS only (even though ports to few web servers available)
Web Server – IIS – Not Free. OS cost applicable Web Server – Free
OS – Windows Server – Not Free OS – Linux is free, Windows is costly
Third Party Hosting Price Cost involved Cost Involved Both are not costly but if you compare, PHP is found to be a little bit cheaper
Development Cost Developer cost Involved Visual Studio Express Editions are free Rapid-Application-Development Model. So development takes less time Developer Cost Involved Free/Open Source IDEs available Much coding involved Both are same but ASP.NET is more on Rapid-Application-Development and PHP is more on Coding
Cross Platform Yes Yes Whatever server side language you use, browsers render only as HTML. But development is not cross-platform even though ASP.NET got ports for Linux available
Code Portability Partial Yes For PHP, a code written on Linux/Apache will work on Windows or any OS/Web Server. But .NET, even though we have ports available, you will require some tweaks to make it run.
Cloud Feasibility Possible Possible Additionally, for ASP.NET -SQL Azure is also available for database hosting.
Mode of source Closed Source Open Source Application developers have no benefits for either it is closed or open UPDATE: Microsoft also opened .NET framework code for reference. Note that it is just for reference. You cannot do anything except reading. A real open source must be able to download, make amendments, re-compile. You cannot make your own .NET versions.
Promoted by Microsoft PHP Community
Customer Support by Owner Yes No
Security Fixes Auto Update – part of OS Need to update separately when available Both parties release fixes for bugs and security issues instantly
Developer Help Community Community Both technologies got fans worldwide. They will provide help and guidance through forums, mail lists, news groups, etc.
Languages C# PHP
VB.NET
Jscript, etc.
Database Any Database Good fit: Microsoft SQL Server Any Database Good fit: MySQL Supports most of the databases
Frameworks / OOPs There is an inbuilt framework (called web forms framework) available which will force developers to use OOPs You can write both procedural and OOPs based code
MVC Microsoft ASP.NET MVC Symfony
Development IDE Recommended: Microsoft Visual Studio Recommended: Zend Studio Even Notepad can be used for coding. PHP is more easy for that, but if you can afford Visual Studio, then ASP.NET.
Any IDE Any IDE
ORM ADO.NET Entity Framework Doctrine
NHibernate
Templating NVelocity Smarty
Extensibility ASP.NET uses Microsoft.NET framework. So you can make use of any functionality available on .NET framework PECL – PHP Extension Community Library
HTTPHandlers
HTTPModules
ISASP Extensions, etc.
Easy to learn Yes Yes Personally I found PHP to be easier for a beginner to learn programming
Recommended for Huge systems? Yes No As per my analysis, PHP is recommended for small-to-medium projects and ASP.NET and JSP for medium-to-big applications UPDATE: If you think about Facebook, please understand that:
1. it uses a re-written PHP and a
2. transformer+compiler called HipHop which transforms PHP code to highly optimized C++ code and then compiles with gcc. We are talking here about the PHP we get for application developers from PHP.NET (as it is).
Content Management Systems DotNetNuke Typo3 Wide variety of options
SharePoint Joomla
N2CMS … Magento …
Advancement Growing very fast Growing with limited speed Micorosft’s team is keen to develop and integrate new features. But since PHP is promoted by community, it takes time to reach that level
Backward Compatibility Old code will work on new framework versions without change Old code might need tweaks to make it work on latest versions
Security IIS must be improved from the past and now a days it is one of the secure web servers Major web servers are secure ASP.NET, PHP, Oss and its servers are mostly secure. Now developers need to make sure their coding is secure.
Performance Faster Faster for small programs and slower for medium-to-big programs Very basic old argument – ASP.NET is compiled and PHP is interpreted (line by line compilation and execution)
Deployment Multiple methods available E.g.: Publish, XCopy, MSI You need to copy/paste code to server somehow (e.g.: FTP)
Some useful features WCF (Windows Communication Foundation), Web Service, .NET Remoting etc. Web Service
ASP.NET AJAX Third party Ajax libraries
Built-in Caching features Third party Caching libraries

I do not claim all I stated above are true, but all that I believe to be true. Also this list is in no way complete. It is time consuming to build a full list, so I included the major points only.

Correct me if any point is wrong or if I missed any important points.