Showing posts with label configuration. Show all posts
Showing posts with label configuration. Show all posts

Wednesday, October 31, 2012

MySQLdb does not commit ???? then read this.

If you are newby for python and want to use mysql database with the language. You might have come across this weird behavior at least once in your python time.

Once you check your db after finish running sql query that insert data to your mysql db you might have surprise to see there is no data inserted at all. Actually i had seen something more weird which is first i install MySQLdb package it was ok, it inserted data as it used to be. But after i install mysql c++ headers it start to act weird (for my case, but usually this is how it should happen... you may find in a while )

The problem to not insert the data is that you have not specified it in your connection. In more simpler manner, MySQLdb is not like other database libraries in other language, you have to specifically tell at the beginning to commit your changes automatically or you have to do it manually each time u run an insert sql. Of course yes if you only use your code only to read the data you dont have to do anything at all.

So there are two ways in MySQLdb to commit the data.

First one is to tell the library to commit it after you execute insert sql statements.



con = MySQLdb.Connect(host=host,user=uname,passwd=pwd,db=db)
#your insert sql statements goes here
con.commit()


Next way is to enable auto commit mode at the beginning.



con = MySQLdb.Connect(host=host,user=uname,passwd=pwd,db=db)
con.autocommit(True)
#your insert sql statements goes here


Happy Coding !!!


Saturday, September 29, 2012

Android HSPA settings & MMS settings for Mobitel


Go to ,
Settings --> Wireless and Network --> Mobile Networks -- > Access Point Names

HSPA settings

Tap menu and select New APN.

Enter the following settings. ( for none and not set fields leave them empty )

Name: Mobitel
APN : mobitel3g
proxy : 192.168.050.163
port : 8080
User Name : not set
Password : not set
Server : not set
MMSC : not set
MMS proxy : not set
MMS port : not set
MCC : 413
MNC : 01
Authentication type : none
APN tpe : internet

Tap menu , tap save and tap back.


MMS settings


Tap menu and select New APN.

Enter the following settings. ( for none and not set fields leave them empty )

Name: MobitelMMS
APN : wapmms
proxy : none
port : none
User Name : not set
Password : not set
Server : not set
MMSC :  http://192.168.050.165
MMS proxy :  192.168.050.163
MMS port : 8080
MCC : 413
MNC : 01
Authentication type : none
APN tpe : mms


Tap menu , tap save and tap back.

Sunday, June 24, 2012

Stop browsing facebook From windows OS

I m sure most of you guys have fed up with facebook already. No doubt it is a huge waste of time. You waste your time that you have for reading, watching movie or most probably time for do studies to browse facebook.

As from medical aspects doctors have recognize the highly addiction to facebook is a mental illness and i m sure most of the facebook users like us have this since we waste approximately 3/4th of our day on facebook.


For me when i logged in to my windows or linux operating systems and start the browser, first thing i do is, type www.facebook.com, go there and see what are the news, status updates and photos of my friends. Then somebody come online and chat with me, some one else join to the chat and so on. Which make my 5 minutes browsing session goes on for more that 6 hours sometimes.

I dont to deactivate my account neither, because it is the only medium that connect all the friends i know since i was in nursery to university. And temporarily deactivation is humiliating since its like you log out and login by blocking your account.

Most of the time i use windows as my operating system (it is dual boot machine). So i did blocked facebook to my windows OS by the operating system level. There are software like anti virus programs which let you do this in more easy way, but it is very easy to undone that too. That is why i used the hard way because no body wants to do the hard things again and again, humans are lazy from their nature.

Let us stop facebook hardway ....

This is a simple method, for non IT people we do little mapping to facebook URL to our localhost so when you type the an URL starting from www.facebook.com it will give you 403 error saying "access forbidden to the content you request" because there in no facebook.com in our local machine. So lets start little hacking then,

1. Go to the location "C:\windows\system32\drivers\etc\"



2. Copy the file named "hosts" to desktop (also copy and back up this file to separate location in case things gone wrong.)

3. Open the copied hosts file with your favorite editing program (notepad, wordpad, notepad++ ) and add the following line to the end of the file and save it back to the desktop.

                    127.0.0.1         www.facebook.com                                 



3. After editing and saving the file back to the Desktop, copy the edited file back to the "C:\windows\system32\drivers\etc\"  location and replace the original file.

4. Check if everything is ok by typing the "www.facebook.com" into your browser's address bar. If things were alright it will give you HTTP 403  or ACCESS FORBIDDEN error. 




Sunday, March 18, 2012

Configure manually Apache HTTPD and PHP in your machine.

There are "WAMP" and "XAMP" softwares that install all three apache httpd web server, php interpreter and mysql server, and automate the configuration process with just few clicks. But just  think of a situation where you have previously installed mysql instance running !


Either you have to uninstall the current instance of mysql server and install one of above "three in one" packs or change the port number of the newly installing my sql server. But what is the point of running two mysql instances at the same machine ???? (adding another service to windows means resources will be eaten more). Even though you uninstall current mysql server and install WAMP or XAMP there might be high chance that you will end up those installations not working due to some conflict with previously installed and now removed mysql instance and the one in WAMP or XAMP.


So it is always better to keep the current mysql instance and configure the other two with the existing one. And after all it is fun! and you can  be proud of your self about what you have done because almost all the php developers depends on wamp and when it comes to the server configuration and deployment environment you cant depend on a WAMP ! its just a development tool (and what if you do you client wants MS SQL server instead of mysql offer in WAMP ? ). So be an adult and do things by your self.


Ok enough talking lets start the work.


First download the latest releases of Apache HTTPd web server, PHP interpreter from the links. (Please download the executable files since that will be helpful with some auto configurations )


Then create a directory called "web" in the location c drive "c:\web". (name of the directory can be anything you like but without spaces, we dont install to "program files" because of the space in file path, try to avoid spaces in file path.)


Installing apache httpd server


Launch the setup (double click on setup.exe) and choose custom. Then choose the directory as "c:\web\apache" and enter the information of your server in to the following window.
( I prefer,
Network Domain - localhost
server name - localhost
Email Address - anything@you.want  If you intend to use the server in local development)


apache-install 
  Click next and choose content to install as showed in below.


apache-install-2 


And finish the setup.


Installing PHP setup.


Launch the setup and when prompt to select a location select the "c:\web\php" as the location.


In next window select the server which u wish to configure the PHP interpreter with shown as below. ( here we choose apacheXXX where XXX is the version of the apache httpd server that you have downloaded and installed previously)


php-install-2 


In next prompt choose the apache configuration directory in our case "c:\web\Apache\conf". 


On next window choose the libraries you wanted to install with PHP.


(Caution!!! some of the modules will not be compatible with the current PHP interpreter version that we are installing this might give us errors when we run the interpreter. If you are a newby most of the time you will miss understand this errors as miss configurations. So its better to leave not installing modules for now since we can add modules by editing "php.ini" manually later.)


Configuring apache server


First you have to add the a map to localhost and your server name if it is not "localhost" that you have entered in the beginning of apache server installation process. To do this open the host file in the "c:\windows\system32\drivers\etc\hosts" location using text editor (Most of the time if you are not in the administrator account you wont be able to save the edited host file. In that case copy the host file to Desktop edit it, save it there and copy back to the location of the original host file by overwriting it).



127.0.0.1 localhost
127.0.0.1 yourDomain


Then we are going to edit apache configuration files. ( keep in mind to use forward slash '/' instead of back slash '\' in file paths ).

(First of all copy and backup the "c:\web\apache\conf\httpd.conf" file in case of things gone wrong)

Open "c:\web\apache\conf\httpd.conf" and search for the lines.

1. DocumentRoot
DocumentRoot "c:/web/Apache/htdocs"

change this to any directory you prefer to use to  store your html and php files. (lets say "c:\web\www").

DocumentRoot "c:/web/www"
2. Then change 

<Directory "c:/web/Apache/htdocs">
to
<Directory "c:/web/www">

3. Add entry for php in the apache configuration file.
#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
PHPIniDir "C:/web/PHP"
LoadModule php5_module "C:/web/PHP/php5apache2_2.dll"
AddType application/x-httpd-php .php
#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL

4. Include index.php to apache directory index files.
DirectoryIndex index.html index.htm index.php




Configuring PHP

(First of all copy and backup the "c:\web\php\php.ini " file in case of things gone wrong) 

Edit php.ini file located in "c:\web\php\php.ini".

1. Change the display errors on.
display_errors = Off
to
display_errors = On

2. Copy all the "php5apache2_2.dll" in php root directory and ext directory to "c:\windows\system32" directory with edited php.ini file.


Adding or removing modules to php.ini

Edit php.ini file and add entries for required modules.

Eg:

[PHP_MCRYPT]
extension=php_mcrypt.dll
[PHP_MYSQL]
extension=php_mysql.dll
[PHP_MYSQLI]
extension=php_mysqli.dll
[PHP_OPENSSL]
extension=php_openssl.dll
[PHP_PDO]
extension=php_pdo.dll
[PHP_SOAP]
extension=php_soap.dll
[PHP_SQLITE]
extension=php_sqlite.dll
[PHP_XMLRPC]
extension=php_xmlrpc.dll
[PHP_ZIP]

Adding MySQL support to PHP


Here i assumed that you have already installed mysql server and configured it. Do not store your mysql host, user and password fields in php.ini file even though php mysql configuration allows to store them.

[MySQLi]

; Maximum number of links.  -1 means no limit.
mysqli.max_links = -1

; Default port number for mysqli_connect().  If unset, mysqli_connect() will use
; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
; compile-time value defined MYSQL_PORT (in that order).  Win32 will only look
; at MYSQL_PORT.
mysqli.default_port = 3306

; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.
mysqli.default_socket =

; Default host for mysql_connect() (doesn't apply in safe mode).
mysqli.default_host =

; Default user for mysql_connect() (doesn't apply in safe mode).
mysqli.default_user =

; Default password for mysqli_connect() (doesn't apply in safe mode).
; Note that this is generally a *bad* idea to store passwords in this file.
; *Any* user with PHP access can run 'echo get_cfg_var("mysqli.default_pw")
; and reveal this password!  And of course, any users with read access to this
; file will be able to reveal the password as well.
mysqli.default_pw =

; Allow or prevent reconnect
mysqli.reconnect = Off

Testing
 



Write the following php code. Store it as index.php in your webroot location. ( here we use "c:\web\www" ).

<?php phpinfo(); ?>



Then open a browser and type localhost in address bar. You will get a similar page as below.