Stored procedures are supported in MySQL 5. A stored procedure is a set of SQL statements that can be stored in the server. Once this has been done, clients don’t need to keep reissuing the individual statements but can refer to the stored procedure instead. This article, I will be explaining, how stored procedures can be called from a PHP script. Create a visdomsoft database. [sql] mysql> CREATE DATABASE visdomsoft; [/sql] Create a customers table [sql] mysql> CREATE TABLE `visdomsoft`.`customers` ( -> `username` VARCHAR( 25 ) NOT NULL , -> `fname` VARCHAR( 25 ) NOT NULL , -> `lname` VARCHAR( 25 ) NOT NULL , -> `email` VARCHAR( 255 ) NOT NULL , -> PRIMARY KEY ( `username` ) -> ) ENGINE = MYISAM ; [/sql] Create a stored procedure to insert information into customers[sql] mysql> delimiter // mysql> USE visdomsoft mysql> CREATE PROCEDURE `customer_insert`(IN username VARCHAR(25),IN fname VARCHAR(25), IN lname VARCHAR(22), IN email VARCHAR(255)) -> BEGIN -> INSERT INTO customers VALUES(username,fname,lname,email); -> END; -> // [/sql] Create a stored procedure to fetch email ID of a customer [sql] mysql> CREATE PROCEDURE `customer_fetch`(IN uname VARCHAR(25), OUT addr VARCHAR(255)) -> BEGIN -> SELECT email INTO addr FROM customers WHERE username = uname; -> END; -> //</code> mysql> delimiter ; [/sql] Testing the stored procedures [sql]mysql> call customer_insert(‘mkmajeed’,’M’,’Kashif’,’ mkmajeed@gmail.com ‘); mysql> call customer_fetch(‘mkmajeed’,@a); Query OK, 0 rows affected (0.00 sec) mysql> select @a; +—————-+ | @a | +—————-+ | mkmajeed@gmail.com | +—————-+ 1 row in set (0.00 sec) [/sql] Write a PHP script that calls stored procedure [php] <?php //Connect to visdomsoft database $link = mysql_connect(‘localhost’,’root’,’password’) or die(mysql_error() . "\n"); mysql_select_db(‘visdomsoft’, $link) or die(mysql_error() . "\n"); //Call customer_insert procedure mysql_query("call customer_insert(‘mkmajeed’,’M’,’Kashif’,’ mkmajeed@gmail.com ‘)") or die(mysql_error() . "\n"); [...]
Network Resources : How to change or setup DNS server IP address on Windows 7
In my Previous article How to change or setup DNS server IP address on Linux, I have mentioned that I will going to write method of changing or setting up DNS server IP address on Microsoft Windows Vista / XP / Server 2003, but I have received number of emails asking me to write the method for Windows 7. so here I am going to write down step by step procedure of How to setup DNS server on Windows 7 . Changing of DNS Server on Windows 7 Click the Start Orb found at the left bottom of your screen. Select Control Panel. Click on view network Status and tasks. Click on Local Area Connection under ‘Active Networks.’ Since I am on wireless network so I am selecting my wireless connection . Click the Properties button. (Windows 7 may prompt you for permission to make network setting changes) Highlight ‘Internet Protocol Version 4′ and click Properties. Click the radio button ‘Use the following DNS server addresses:’ and type in desired addresses in the Preferred DNS server and Alternate DNS server fields Click OK button, then the Close button, then Close again. Finally, close the Network and Sharing Center window. At this point, it is highly suggest that you flush your DNS resolver cache and web browser caches to ensure that your new configuration settings take effect.
Network Resources : How to change or setup DNS server IP address on Linux
Domain name service is accountable for associating domain names with IP address, for example domain yahoo.com is easy to remember than IP address 202.66.66.12. In my Previous article Free fast public DNS servers list for your network, I have mentioned free public DNS being offered by some quality providers. Here I am going to write down the method how you can setup DNS server IPs on Linux machine. In Linux, local name resolution is done via /etc/hosts file. In case of a small network, use /etc/hosts file. To configure Linux as DNS client you need to edit or modify /etc/resolv.conf file. This file contains information that allows a computer connected to the Internet to convert alpha-numeric names into the numeric IP addresses that are required for access to network resource over the Internet. This file contains DNS server IP addresses that attempt to resolve names into addresses for any node available on the network. SETTING UP DNS SERVER IP Steps to configure Linux as DNS client, first login as a root user (use su command): Step # 1: Open /etc/resolv.conf file: # vi /etc/resolv.conf Step #2: Add your ISP nameserver as follows: search isp.com nameserver 202.54.1.110 nameserver 202.54.1.112 nameserver 8.8.8.8 Note Max. three nameserver can be used/defined at a time. Step # 3:Test setup nslookup or dig command: $ dig www.google.com $ nslookup www.google.com In my next post i will let you know How to change or setup DNS server IP address on Microsoft Windows Vista / XP / Server 2003.
