<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>The How To Do Things Blog » Database</title>
	
	<link>http://www.howtoplaza.com</link>
	<description>How to wisdom from across the Internet — want to know how to do something? You may find the solution here.</description>
	<lastBuildDate>Thu, 08 Jul 2010 18:58:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/howtoplazaDatabase" /><feedburner:info uri="howtoplazadatabase" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:browserFriendly></feedburner:browserFriendly><item>
		<title>How to modify the structure of a MySQL table</title>
		<link>http://www.howtoplaza.com/how-to-modify-the-structure-of-a-mysql-table</link>
		<comments>http://www.howtoplaza.com/how-to-modify-the-structure-of-a-mysql-table#comments</comments>
		<pubDate>Sat, 12 Jun 2010 14:15:40 +0000</pubDate>
		<dc:creator>Danny Garcia</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.howtoplaza.com/?p=970</guid>
		<description><![CDATA[Need to modify or alter the structure of a MySQL table that you created a while ago? Before you carry out the changes you must know that if you haphazardly change the structure of your MySQL table you might lose your data. So make sure you know what you are doing. You may lose your [...]]]></description>
			<content:encoded><![CDATA[<p></p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.howtoplaza.com%2Fhow-to-modify-the-structure-of-a-mysql-table"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.howtoplaza.com%2Fhow-to-modify-the-structure-of-a-mysql-table&amp;source=howtoplaza&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Need to modify or alter the structure of a MySQL table that you created a while ago? Before you carry out the changes you must know that if you haphazardly change the structure of your MySQL table you might lose your data. So make sure you know what you are doing.</p>
<p>You may lose your data while making the following changes in your MySQL table:</p>
<ul>
<li>By altering the type &#8212; from integer to text or some other type</li>
<li>By deleting the column</li>
</ul>
<p>Now coming back to altering the structure.</p>
<p>Suppose a while ago you created a MySQL table called &#8220;tourists&#8221; with the following structure.</p>
<p>name varchar(255)<br />destination varchar(255)<br />id integer not null auto_increment</p>
<p>Then you realized the name should in fact be in two separate fields, viz. first_name and last_name. Now whatever data is there in the current name field you can have it in the new first_name field and in the new last_name field you can manually enter the new values. But let us see how you can change the name to first_name and last_name:</p>
<p class="code">
ALTER TABLE &#8216;tourists&#8217; CHANGE &#8216;name&#8217; &#8216;first_name&#8217; VARCHAR(255);<br />ALTER TABLE &#8216;tourists&#8217; ADD COLUMN &#8216;last_name&#8217; VARCHAR(255);
</p>
<p>We have in fact executed here two commands simultaneously to change the structure of our MySQL table.</p>
<p>This is highly improbable but you can also change the type of a field. Let&#8217;s say you want name to be an integer. You change it like this:</p>
<p class="code">ALTER TABLE &#8216;tourists&#8217; CHANGE &#8216;name&#8217; &#8216;name&#8217; INTEGER NOT NULL</p>
<p>You can also use MODIFY to change a column definition:</p>
<p class="code">ALTER TABLE &#8216;tourists&#8217; MODIFY &#8216;name&#8217; INTEGER NOT NULL</p></p>
<div style="float:right"><a href="http://www.google.com/reader/link?url=http://www.howtoplaza.com/how-to-modify-the-structure-of-a-mysql-table&title=How to modify the structure of a MySQL table&srcTitle=The How To Do Things Blog&srcURL=http://www.howtoplaza.com"target="_blank" rel=""><img border="0" src="http://www.howtoplaza.com/wp-content/plugins/wp-google-buzz/icon/10.png" style="opacity:1;filter:alpha(opacity=100)" onmouseover="this.style.opacity=0.8;this.filters.alpha.opacity=80" onmouseout="this.style.opacity=1;this.filters.alpha.opacity=100"/> </a></div>]]></content:encoded>
			<wfw:commentRss>http://www.howtoplaza.com/how-to-modify-the-structure-of-a-mysql-table/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to store your web or online form data into a MySQL database using PHP</title>
		<link>http://www.howtoplaza.com/store-online-form-data-into-mysql-database-using-php</link>
		<comments>http://www.howtoplaza.com/store-online-form-data-into-mysql-database-using-php#comments</comments>
		<pubDate>Fri, 21 May 2010 14:54:22 +0000</pubDate>
		<dc:creator>Sarah Watts</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Data Processing]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[Online Forms]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Web Forms]]></category>

		<guid isPermaLink="false">http://www.howtoplaza.com/?p=851</guid>
		<description><![CDATA[You can either store your web or online form data into a database using PHP &#8212; MySQL or some other &#8212; or you can get it mailed to you. Read how to connect to MySQL database with PHP. It&#8217;s preferable to mail the data to you each time someone fills up your web form but [...]]]></description>
			<content:encoded><![CDATA[<p></p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.howtoplaza.com%2Fstore-online-form-data-into-mysql-database-using-php"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.howtoplaza.com%2Fstore-online-form-data-into-mysql-database-using-php&amp;source=howtoplaza&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>You can either store your web or online form data into a database using PHP &#8212; MySQL or some other &#8212; or you can get it mailed to you. Read <a href="http://www.howtoplaza.com/how-to-connect-to-mysql-database-with-php">how to connect to MySQL database with PHP</a>. It&#8217;s preferable to mail the data to you each time someone fills up your web form but for later analysis it&#8217;s advised that you also store it somewhere, especially when you are gathering information like age, gender and the reason of visiting your website.</p>
<p>Although there is a multitude of databases and languages available to you, most web hosts provide PHP and MySQL so we&#8217;ll base our example on this prevalent database server. We&#8217;ll first create an online form that accept the following information:</p>
<ul>
<li>Name</li>
<li>Age</li>
<li>Gender</li>
<li>Country</li>
</ul>
<p>To store this information into your MySQL database either should already be having a table that can accommodate this data, or you should create it. In your hosting account (<em>or local host if you have installed the MySQL database on your PC</em>) you can easily go to phpmyadmin and create a table &#8220;mydata&#8221; (<em>you can have any name</em>):</p>
<p class="code">
CREATE TABLE mydata (<br />id INTEGER NOT NULL AUTO_INCREMENT,<br />name VARCHAR(255),<br />age integer,<br />gender VHARCHAR(20),<br />country VARCHAR(255),<br />PRIMARY KEY (id));
</p>
<p>And now your table is all ready to store your web form data.</p>
<p>The code for the form goes like this:</p>
<p class="code">
&lt;form name=&#8221;user_details&#8221; id=&#8221;user_details&#8221; method=&#8221;post&#8221; action=&#8221;save-in-database.php&#8221;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;p&gt;&lt;label&gt;Enter Name:&lt;/label&gt; &lt;input type=&#8221;text&#8221; name=&#8221;name&#8221; id=&#8221;name&#8221; /&gt;&lt;/p&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;p&gt;&lt;label&gt;Enter Age:&lt;/label&gt; &lt;input type=&#8221;text&#8221; name=&#8221;age&#8221; id=&#8221;age&#8221; /&gt;&lt;/p&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;p&gt;&lt;label&gt;Enter Gender:&lt;/label&gt; &lt;input type=&#8221;text&#8221; name=&#8221;gender&#8221; id=&#8221;gender&#8221; /&gt;&lt;/p&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;p&gt;&lt;label&gt;Enter Country:&lt;/label&gt; &lt;input type=&#8221;text&#8221; name=&#8221;country&#8221; id=&#8221;country&#8221; /&gt;&lt;/p&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;p&gt;&lt;input type=&#8221;submit&#8221; name=&#8221;s1&#8243; value=&#8221;Submit&#8221; /&gt; &lt;input type=&#8221;reset&#8221; name=&#8221;r1&#8243; value=&#8221;Reset&#8221; /&gt;&lt;/p&gt;<br />&lt;/form&gt;
</p>
<p>We could have jazzed it up a bit more with formatting the date field and using a dropdown for countries, but right now our main purpose is to know how to store your online form data into a MySQL database. As you can see above, the action attribute refers to the file &#8220;save-in-database.php&#8221; and this is the file that receives the information from the form and saves it.</p>
<p>First, let is store the form details in local PHP variables:</p>
<p class="code">
&lt;?php<br />$name = $_POST['name'];<br />$age = $_POST['age'];<br />$gender = $_POST['age'];<br />$country = $_POST['country'];<br />?&gt;
</p>
<p>We use POST because in the method attribute of the form we specified &#8220;post&#8221;. You can use either &#8220;post&#8221; or &#8220;get&#8221;. Once you have stored the form data in the variables you need to connect to the MySQL database server and we&#8217;re going to borrow the code from the blog post link mentioned above:</p>
<p class="code">
&lt;?php<br />$host=&#8221;mysql.yourdomain.com&#8221;;<br />$user_name=&#8221;peter&#8221;;<br />$pwd=&#8221;F$5tBGtr&#8221;;<br />$database_name=&#8221;our_clients&#8221;;<br />$db=mysql_connect($host, $user_name, $pwd);<br />if (mysql_error() &gt; &#8220;&#8221;) print mysql_error() . &#8220;&lt;br&gt;&#8221;;<br />mysql_select_db($database_name, $db);<br />if (mysql_error() &gt; &#8220;&#8221;) print mysql_error() . &#8220;&lt;br&gt;&#8221;;<br />?&gt;
</p>
<p>Once we have successfully established the MySQL database connection, we&#8217;ll use PHP&#8217;s inbuilt MySQL functions to store the values into the database table &#8220;mydata&#8221;:</p>
<p class="code">
&lt;?php<br />$query = &#8220;insert into mydata (name, age, gender, country) values (&#8216;&#8221; . $name . &#8220;&#8216;, &#8221; . $age . &#8220;, &#8216;&#8221; . $gender . &#8220;&#8216;, &#8216;&#8221; . $country . &#8220;&#8216;)&#8221;;</p>
<p>$qresult = mysql_query($query);<br />?&gt;
</p>
<p>You create a simple MySQL command, store it in a string and then execute it by using the PHP function mysql_query(). There are many validations you can carry out to improve and maintain data integrity, but this is a simple example of storing your online form data in MySQL database using PHP.</p>
<div style="float:right"><a href="http://www.google.com/reader/link?url=http://www.howtoplaza.com/store-online-form-data-into-mysql-database-using-php&title=How to store your web or online form data into a MySQL database using PHP&srcTitle=The How To Do Things Blog&srcURL=http://www.howtoplaza.com"target="_blank" rel=""><img border="0" src="http://www.howtoplaza.com/wp-content/plugins/wp-google-buzz/icon/10.png" style="opacity:1;filter:alpha(opacity=100)" onmouseover="this.style.opacity=0.8;this.filters.alpha.opacity=80" onmouseout="this.style.opacity=1;this.filters.alpha.opacity=100"/> </a></div>]]></content:encoded>
			<wfw:commentRss>http://www.howtoplaza.com/store-online-form-data-into-mysql-database-using-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to connect to MySQL database with PHP</title>
		<link>http://www.howtoplaza.com/how-to-connect-to-mysql-database-with-php</link>
		<comments>http://www.howtoplaza.com/how-to-connect-to-mysql-database-with-php#comments</comments>
		<pubDate>Wed, 19 May 2010 15:37:54 +0000</pubDate>
		<dc:creator>Sarah Watts</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Website Promotion]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.howtoplaza.com/?p=840</guid>
		<description><![CDATA[You can create really cool database applications usind PHP and MySQL. In fact if you are using WordPress you are already using PHP and MySQL. You need to first connect to your MySQL database server before you can manipulate tables created in a particular database. In order to connect, you need the following information: MySQL [...]]]></description>
			<content:encoded><![CDATA[<p></p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.howtoplaza.com%2Fhow-to-connect-to-mysql-database-with-php"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.howtoplaza.com%2Fhow-to-connect-to-mysql-database-with-php&amp;source=howtoplaza&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>You can create really cool database applications usind PHP and MySQL. In fact if you are using WordPress you are already using PHP and MySQL. You need to first connect to your MySQL database server before you can manipulate tables created in a particular database. In order to connect, you need the following information:</p>
<ul>
<li>MySQL server host link</li>
<li>User name</li>
<li>User password</li>
<li>Database name</li>
</ul>
<p>If you are hosting your website through a web hosting company, they may have you use &#8220;localhost&#8221; as your MySQL server host link. Mostly, you use &#8220;localhost&#8221; when you have installed the server on your own machine. In many cases, you may also have something like &#8220;mysql.yourdomain.com&#8221;. The rest of the things are easily understandable.</p>
<p>Different people may have different ways of connecting to MySQL database with PHP, but here is a straightforward way:</p>
<p class="code">
&lt;?php<br />$host=&#8221;mysql.yourdomain.com&#8221;;<br />$user_name=&#8221;peter&#8221;;<br />$pwd=&#8221;F$5tBGtr&#8221;;<br />$database_name=&#8221;our_clients&#8221;;<br />$db=mysql_connect($host, $user_name, $pwd);<br />if (mysql_error() &gt; &#8220;&#8221;) print mysql_error() . &#8220;&lt;br&gt;&#8221;;<br />mysql_select_db($database_name, $db);<br />if (mysql_error() &gt; &#8220;&#8221;) print mysql_error() . &#8220;&lt;br&gt;&#8221;;<br />?&gt;
</p>
<p>This way you can easily connect to your MySQL database with PHP. You can easily have this code in a function and then call that function:</p>
<p class="code">
&lt;?php<br />function connect2database()<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$host=&#8221;mysql.yourdomain.com&#8221;;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$user_name=&#8221;peter&#8221;;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$pwd=&#8221;F$5tBGtr&#8221;;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$database_name=&#8221;our_clients&#8221;;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$db=mysql_connect($host, $user_name, $pwd);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (mysql_error() &gt; &#8220;&#8221;) print mysql_error() . &#8220;&lt;br&gt;&#8221;;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mysql_select_db($database_name, $db);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (mysql_error() &gt; &#8220;&#8221;) print mysql_error() . &#8220;&lt;br&gt;&#8221;;<br />}<br />?&gt;
</p>
<p>Once this function is called on a particular page, you don&#8217;t need to call it again and again every time you run a MySQL function in PHP, unless due to some reason you had to close the database.</p>
<div style="float:right"><a href="http://www.google.com/reader/link?url=http://www.howtoplaza.com/how-to-connect-to-mysql-database-with-php&title=How to connect to MySQL database with PHP&srcTitle=The How To Do Things Blog&srcURL=http://www.howtoplaza.com"target="_blank" rel=""><img border="0" src="http://www.howtoplaza.com/wp-content/plugins/wp-google-buzz/icon/10.png" style="opacity:1;filter:alpha(opacity=100)" onmouseover="this.style.opacity=0.8;this.filters.alpha.opacity=80" onmouseout="this.style.opacity=1;this.filters.alpha.opacity=100"/> </a></div>]]></content:encoded>
			<wfw:commentRss>http://www.howtoplaza.com/how-to-connect-to-mysql-database-with-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to update a MySQL table with PHP</title>
		<link>http://www.howtoplaza.com/how-to-update-a-mysql-table-with-php</link>
		<comments>http://www.howtoplaza.com/how-to-update-a-mysql-table-with-php#comments</comments>
		<pubDate>Sun, 21 Feb 2010 14:02:27 +0000</pubDate>
		<dc:creator>Sarah Watts</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.howtoplaza.com/?p=730</guid>
		<description><![CDATA[You can update a MySQL table, either with PHP or through its command prompt, by adding (inserting) new records to it or modifying the existing records. But in this tutorial we&#8217;re going to explore how you can update a MySQL table with PHP. You may have to do this when creating an online application in [...]]]></description>
			<content:encoded><![CDATA[<p></p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.howtoplaza.com%2Fhow-to-update-a-mysql-table-with-php"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.howtoplaza.com%2Fhow-to-update-a-mysql-table-with-php&amp;source=howtoplaza&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>You can update a MySQL table, either with PHP or through its command prompt, by adding (<em>inserting</em>) new records to it or modifying the existing records. But in this tutorial we&#8217;re going to explore how you can update a MySQL table with PHP. You may have to do this when creating an online application in PHP that involves saving new information or modifying existing information.</p>
<p>In order to modify a MySQL table you first need to establish a database connection. In PHP, you can establish a MySQL database connection using the following lines of code:</p>
<p class="code">&lt;?php<br />$host=&#8221;localhost&#8221;;<br />$user_name=&#8221;username&#8221;;<br />$pwd=&#8221;password&#8221;;<br />$database_name=&#8221;your_database&#8221;;<br />$db=mysql_connect($host, $user_name, $pwd);<br />if (mysql_error() &gt; &#8220;&#8221;) print mysql_error() . &#8220;&lt;br&gt;&#8221;;<br />mysql_select_db($database_name, $db);<br />if (mysql_error() &gt; &#8220;&#8221;) print mysql_error() . &#8220;&lt;br&gt;&#8221;;<br />?&gt;</p>
<p>This basically first connects to your MySQL server (<em>in most of the cases it is localhost but if it is different you&#8217;ll get this information from your host</em>), and then selects the database that contains the table.</p>
<p>Just to make it a bit convenient let&#8217;s assume the table name is students having the following structure:</p>
<ul>
<li>first_name</li>
<li>last_name</li>
<li>roll_number</li>
<li>attendance</li>
</ul>
<p>And we&#8217;ll also suppose that a form is being submitted through POST and the following variables contain the information to be saved:</p>
<p class="code">&lt;?php<br />$fname=&#8221;Some first name&#8221;;<br />$lname=&#8221;Some last name&#8221;;<br />$rollnumber=&#8221;Some roll number&#8221;;<br />$attendance=150;<br />?&gt;</p>
<p>If this is a new record being saved in the MySQL table you&#8217;ll use the following PHP code:</p>
<p class="code">&lt;?php<br />$r = mysql_query(&#8220;insert into students (first_name, last_name, roll_number, attendance) values (&#8216;&#8221; . $fname . &#8220;&#8216;, &#8216;&#8221; . $lname . &#8220;&#8216;, &#8216;&#8221; . $rollnumber . &#8220;&#8216;, &#8221; . $attendance . &#8220;)&#8221;;<br />?&gt;</p>
<p>The three single quotes are actually single quotes within double quotes because when you are saving alphanumeric values you have to enclose them within quotes. The quotes here may appear &#8220;fancy&#8221; due to the selected font of the blog, otherwise they have to be simple quotes.</p>
<p>Similarly, if you want to update existing values in a MySQL table you use the following PHP code:</p>
<p class="code">&lt;?php<br />$r = mysql_query(&#8220;update students set first_name=&#8217;&#8221; . $fname . &#8220;&#8216;, last_name=&#8217;&#8221; . $lname . &#8220;&#8216;, roll_number=&#8217;&#8221; . $rollnumber . &#8220;&#8216;, attendance=&#8221; . $attendance;<br />?&gt;</p>
<p>But the problem here is, if you simply use the update command like this, you may end up updating a record where the pointer currently is, whereas you&#8217;d like to update a selected record. Suppose you want to update the record of a student with roll number &#8220;120956&#8243;. You do it like this:</p>
<p class="code">&lt;?<br />$r = mysql_query(&#8220;update students set first_name=&#8217;&#8221; . $fname . &#8220;&#8216;, last_name=&#8217;&#8221; . $lname . &#8220;&#8216;, roll_number=&#8217;&#8221; . $rollnumber . &#8220;&#8216;, attendance=&#8221; . $attendance . &#8221; where roll_number=&#8217;120956&#8242;&#8221;;<br />?&gt;</p>
<p>This is how you can update a MySQL table with PHP.</p>
<div style="float:right"><a href="http://www.google.com/reader/link?url=http://www.howtoplaza.com/how-to-update-a-mysql-table-with-php&title=How to update a MySQL table with PHP&srcTitle=The How To Do Things Blog&srcURL=http://www.howtoplaza.com"target="_blank" rel=""><img border="0" src="http://www.howtoplaza.com/wp-content/plugins/wp-google-buzz/icon/10.png" style="opacity:1;filter:alpha(opacity=100)" onmouseover="this.style.opacity=0.8;this.filters.alpha.opacity=80" onmouseout="this.style.opacity=1;this.filters.alpha.opacity=100"/> </a></div>]]></content:encoded>
			<wfw:commentRss>http://www.howtoplaza.com/how-to-update-a-mysql-table-with-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to install MySQL-Admin in Ubuntu</title>
		<link>http://www.howtoplaza.com/how-to-install-mysql-admin-in-ubuntu</link>
		<comments>http://www.howtoplaza.com/how-to-install-mysql-admin-in-ubuntu#comments</comments>
		<pubDate>Mon, 26 Oct 2009 12:42:46 +0000</pubDate>
		<dc:creator>Sarah Watts</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.howtoplaza.com/?p=689</guid>
		<description><![CDATA[So you have finally got MySQL running in Ubuntu. Now how to manipulate the database? You can open the Terminal window and use the MySQL command prompt but it can become really laborious after a while, especially if you&#8217;ve been using some sort of GUI in Windows to work with MySQL. Although there are several [...]]]></description>
			<content:encoded><![CDATA[<p></p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.howtoplaza.com%2Fhow-to-install-mysql-admin-in-ubuntu"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.howtoplaza.com%2Fhow-to-install-mysql-admin-in-ubuntu&amp;source=howtoplaza&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>So you have finally got MySQL running in Ubuntu. Now how to manipulate the database? You can open the Terminal window and use the MySQL command prompt but it can become really laborious after a while, especially if you&#8217;ve been using some sort of GUI in Windows to work with MySQL. Although there are several options, in this blog post we&#8217;re installing mysql-admin. Conventionally people use the command prompt to install software, but this should be present in the repository.</p>
<p>Go to System -&gt; Administration -&gt; Synaptic Package Manager</p>
<p>It gives you this window (<em>it asks for your user password before the window</em>):</p>
<p><a href="http://www.howtoplaza.com/wp-content/uploads/2009/10/Screenshot-Synaptic-Package-Manager.png" style="text-decoration:none"><img border="0" src="http://www.howtoplaza.com/wp-content/uploads/2009/10/Screenshot-Synaptic-Package-Manager-300x220.png" alt="Screenshot-Synaptic-Package-Manager" title="Screenshot-Synaptic-Package-Manager" width="300" height="220" class="aligncenter size-medium wp-image-690" /></a></p>
<p>Search for mysql-admin. Mark it, and then click Apply. After it has been installed, you&#8217;ll need to run MySQL Query Browser in order to view databases. It&#8217;s not as elaborate as the Windows versions of many GUIs, but it does the job better than the command prompt.</p>
<div style="float:right"><a href="http://www.google.com/reader/link?url=http://www.howtoplaza.com/how-to-install-mysql-admin-in-ubuntu&title=How to install MySQL-Admin in Ubuntu&srcTitle=The How To Do Things Blog&srcURL=http://www.howtoplaza.com"target="_blank" rel=""><img border="0" src="http://www.howtoplaza.com/wp-content/plugins/wp-google-buzz/icon/10.png" style="opacity:1;filter:alpha(opacity=100)" onmouseover="this.style.opacity=0.8;this.filters.alpha.opacity=80" onmouseout="this.style.opacity=1;this.filters.alpha.opacity=100"/> </a></div>]]></content:encoded>
			<wfw:commentRss>http://www.howtoplaza.com/how-to-install-mysql-admin-in-ubuntu/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to update or change data in a MySQL table</title>
		<link>http://www.howtoplaza.com/how-to-update-or-change-data-in-a-mysql-table</link>
		<comments>http://www.howtoplaza.com/how-to-update-or-change-data-in-a-mysql-table#comments</comments>
		<pubDate>Sat, 18 Apr 2009 09:45:31 +0000</pubDate>
		<dc:creator>Sarah Watts</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.howtoplaza.com/?p=571</guid>
		<description><![CDATA[Changing data in a MySQL table using command line command is not as complicated as it sounds, and the basic problem is the way commands are written in various tutorials and manuals. If you want to update data in a MySQL table, alter a column or a low, you can modify your MySQL command accordingly. [...]]]></description>
			<content:encoded><![CDATA[<p></p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.howtoplaza.com%2Fhow-to-update-or-change-data-in-a-mysql-table"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.howtoplaza.com%2Fhow-to-update-or-change-data-in-a-mysql-table&amp;source=howtoplaza&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Changing data in a MySQL table using command line command is not as complicated as it sounds, and the basic problem is the way commands are written in various tutorials and manuals. If you want to update data in a MySQL table, alter a column or a low, you can modify your MySQL command accordingly.</p>
<p>Suppose you want to change data in a single MySQL table cell. In order to achieve this you need to know the name of the column that contains the cell, the row number, or some trait that can uniquely identify that cell. Normally, a complete row in a MySQL table is a complete record and this record is distinguished by a unique record ID, let is say, &#8220;rec_id&#8221;. Suppose the cell you want to change belongs to rec_id 678 and the name of the cell is &#8220;first_name&#8221;. Let the MySQL table be &#8220;students&#8221;. This is how you change the first_name:</p>
<p><span class="code">update students set first_name=&#8217;Suba&#8217; where rec_id=678;</span></p>
<p>Isn&#8217;t it a straightforward command? No matter what value first_name originally contains, it now has Suba in it. Notice that you don&#8217;t write &#8220;update table students&#8221;, you simply write &#8220;update students&#8221;.</p>
<div style="float:right"><a href="http://www.google.com/reader/link?url=http://www.howtoplaza.com/how-to-update-or-change-data-in-a-mysql-table&title=How to update or change data in a MySQL table&srcTitle=The How To Do Things Blog&srcURL=http://www.howtoplaza.com"target="_blank" rel=""><img border="0" src="http://www.howtoplaza.com/wp-content/plugins/wp-google-buzz/icon/10.png" style="opacity:1;filter:alpha(opacity=100)" onmouseover="this.style.opacity=0.8;this.filters.alpha.opacity=80" onmouseout="this.style.opacity=1;this.filters.alpha.opacity=100"/> </a></div>]]></content:encoded>
			<wfw:commentRss>http://www.howtoplaza.com/how-to-update-or-change-data-in-a-mysql-table/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to backup your WordPress blog posts</title>
		<link>http://www.howtoplaza.com/how-to-backup-your-wordpress-blog-posts</link>
		<comments>http://www.howtoplaza.com/how-to-backup-your-wordpress-blog-posts#comments</comments>
		<pubDate>Thu, 16 Apr 2009 17:10:41 +0000</pubDate>
		<dc:creator>Sarah Watts</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[maintenance]]></category>

		<guid isPermaLink="false">http://www.howtoplaza.com/how-to-backup-your-wordpress-blog-posts/</guid>
		<description><![CDATA[You must backup your WordPress blog posts since you work so hard at protecting them and then publishing them. Taking regular backups of your WordPress blog posts can be very simple and it can also be a bit complicated.&#160; It depends upon the kind of backup you would like to take.&#160; There are some WordPress [...]]]></description>
			<content:encoded><![CDATA[<p></p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.howtoplaza.com%2Fhow-to-backup-your-wordpress-blog-posts"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.howtoplaza.com%2Fhow-to-backup-your-wordpress-blog-posts&amp;source=howtoplaza&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>You must backup your WordPress blog posts since you work so hard at protecting them and then publishing them. Taking regular backups of your WordPress blog posts can be very simple and it can also be a bit complicated.&#160; It depends upon the kind of backup you would like to take.&#160; There are some WordPress backup plug-ins that can automatically take daily backups and e-mail files to a designated e-mail account.</p>
<p>First, let us explore the easiest way of taking the WordPress backups.</p>
<p>1 Log in to your WordPress admin are by going to <a href="http://yourdomain.com/blogpath/wp-admin">http://yourdomain.com/blogpath/wp-admin</a>.</p>
<p><img title="wordpress-backup1" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="139" alt="wordpress-backup1" src="http://www.howtoplaza.com/images/HowtobackupyourWordPressblogposts_120C3/wordpressbackup1.gif" width="169" border="0" /></p>
<p>2. Under the Tools menu, click Export.</p>
<p><a href="http://www.howtoplaza.com/images/HowtobackupyourWordPressblogposts_120C3/wordpressbackup2.gif"><img title="wordpress-backup2" style="border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; border-left: 0px; margin-right: auto; border-bottom: 0px" height="153" alt="wordpress-backup2" src="http://www.howtoplaza.com/images/HowtobackupyourWordPressblogposts_120C3/wordpressbackup2_thumb.gif" width="368" border="0" /></a> </p>
<p>3. Click the “Download Export File” button. This allows you to save an XML file on to your local machine.</p>
<p>Whenever you want, you can import the same file and restore your blog posts.</p>
<div style="float:right"><a href="http://www.google.com/reader/link?url=http://www.howtoplaza.com/how-to-backup-your-wordpress-blog-posts&title=How to backup your WordPress blog posts&srcTitle=The How To Do Things Blog&srcURL=http://www.howtoplaza.com"target="_blank" rel=""><img border="0" src="http://www.howtoplaza.com/wp-content/plugins/wp-google-buzz/icon/10.png" style="opacity:1;filter:alpha(opacity=100)" onmouseover="this.style.opacity=0.8;this.filters.alpha.opacity=80" onmouseout="this.style.opacity=1;this.filters.alpha.opacity=100"/> </a></div>]]></content:encoded>
			<wfw:commentRss>http://www.howtoplaza.com/how-to-backup-your-wordpress-blog-posts/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to copy the structure of one MySQL table to another without copying data</title>
		<link>http://www.howtoplaza.com/how-to-copy-the-structure-of-one-mysql-table-to-another-without-copying-data</link>
		<comments>http://www.howtoplaza.com/how-to-copy-the-structure-of-one-mysql-table-to-another-without-copying-data#comments</comments>
		<pubDate>Sat, 11 Apr 2009 12:12:15 +0000</pubDate>
		<dc:creator>Sarah Watts</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.howtoplaza.com/how-to-copy-the-structure-of-one-mysql-table-to-another-without-copying-data/</guid>
		<description><![CDATA[In MySQL sometimes you have to create a copy of an existing table. For instance, you would like to save some data in a temporary table before finally transferring it to the main table. You basically copy the structure of one table to another. You can create a blank table, and you can even transfer [...]]]></description>
			<content:encoded><![CDATA[<p></p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.howtoplaza.com%2Fhow-to-copy-the-structure-of-one-mysql-table-to-another-without-copying-data"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.howtoplaza.com%2Fhow-to-copy-the-structure-of-one-mysql-table-to-another-without-copying-data&amp;source=howtoplaza&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>In MySQL sometimes you have to create a copy of an existing table. For instance, you would like to save some data in a temporary table before finally transferring it to the main table. You basically copy the structure of one table to another. You can create a blank table, and you can even transfer the existing data into the newly created table. In this post, we’ll simply copy the structure of one MySQL table to another. This is how you do it:</p>
<div class="code">
<p>create table table2 like table1</p>
</p></div>
<p>A very simple command indeed. It creates a new table, “table2” by copying the structure of “table1”.</p>
<div style="float:right"><a href="http://www.google.com/reader/link?url=http://www.howtoplaza.com/how-to-copy-the-structure-of-one-mysql-table-to-another-without-copying-data&title=How to copy the structure of one MySQL table to another without copying data&srcTitle=The How To Do Things Blog&srcURL=http://www.howtoplaza.com"target="_blank" rel=""><img border="0" src="http://www.howtoplaza.com/wp-content/plugins/wp-google-buzz/icon/10.png" style="opacity:1;filter:alpha(opacity=100)" onmouseover="this.style.opacity=0.8;this.filters.alpha.opacity=80" onmouseout="this.style.opacity=1;this.filters.alpha.opacity=100"/> </a></div>]]></content:encoded>
			<wfw:commentRss>http://www.howtoplaza.com/how-to-copy-the-structure-of-one-mysql-table-to-another-without-copying-data/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to manage MySQL easily on your PC</title>
		<link>http://www.howtoplaza.com/how-to-manage-mysql-easily-on-your-pc</link>
		<comments>http://www.howtoplaza.com/how-to-manage-mysql-easily-on-your-pc#comments</comments>
		<pubDate>Wed, 25 Mar 2009 20:22:49 +0000</pubDate>
		<dc:creator>Sarah Watts</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[gui]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[utilities]]></category>
		<category><![CDATA[windows xp]]></category>

		<guid isPermaLink="false">http://www.howtoplaza.com/?p=534</guid>
		<description><![CDATA[MySQL is a freesource relational database application that is prevalently used these days to manage database-centric applications. The best examples are WordPress and PHPNuke. You can also install MySQL on your local machine whether it is running on Windows XP or a Linux distribution such as Ubuntu, and run it as a server. But managing [...]]]></description>
			<content:encoded><![CDATA[<p></p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.howtoplaza.com%2Fhow-to-manage-mysql-easily-on-your-pc"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.howtoplaza.com%2Fhow-to-manage-mysql-easily-on-your-pc&amp;source=howtoplaza&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>MySQL is a freesource relational database application that is prevalently used these days to manage database-centric applications. The best examples are WordPress and PHPNuke.</p>
<p>You can also install MySQL on your local machine whether it is running on Windows XP or a Linux distribution such as Ubuntu, and run it as a server. But managing databases and tables using command prompts can really be a big pain. You need GUI software that enables you to control and manipulate your databases and tables in MySQL.</p>
<p>Some of the applications that can help you manage MySQL easily on your PC are:</p>
<ul>
<li><a href="http://www.mysqlfront.de/">MySQL-Front</a> (one of the oldest, and my favorite)</li>
<li><a href="http://www.heidisql.com/">HeidiSQL</a> (Nice, I&#8217;m currently using this)</li>
<li><a href="http://www.phpmyadmin.net/home_page/index.php">PHPMyAdmin</a> (this comes with every hosting package, and you can also install it on your local machine)</li>
<li><a href="http://www.webyog.com/en/index.php">SQLyog MySQL GUI</a> (wasn&#8217;t very happy with it)</li>
</ul>
<p>These, and some more applications are discussed in <a href="http://www.smashingmagazine.com/2009/03/25/mysql-admin-and-development-tools-round-up/">this post on SmashingMagazine</a>.</p>
<div style="float:right"><a href="http://www.google.com/reader/link?url=http://www.howtoplaza.com/how-to-manage-mysql-easily-on-your-pc&title=How to manage MySQL easily on your PC&srcTitle=The How To Do Things Blog&srcURL=http://www.howtoplaza.com"target="_blank" rel=""><img border="0" src="http://www.howtoplaza.com/wp-content/plugins/wp-google-buzz/icon/10.png" style="opacity:1;filter:alpha(opacity=100)" onmouseover="this.style.opacity=0.8;this.filters.alpha.opacity=80" onmouseout="this.style.opacity=1;this.filters.alpha.opacity=100"/> </a></div>]]></content:encoded>
			<wfw:commentRss>http://www.howtoplaza.com/how-to-manage-mysql-easily-on-your-pc/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to handle MySQL errors in php</title>
		<link>http://www.howtoplaza.com/how-to-handle-mysql-errors-in-php</link>
		<comments>http://www.howtoplaza.com/how-to-handle-mysql-errors-in-php#comments</comments>
		<pubDate>Sat, 14 Jun 2008 17:57:39 +0000</pubDate>
		<dc:creator>Sarah Watts</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[MySQL errors]]></category>
		<category><![CDATA[php errors]]></category>

		<guid isPermaLink="false">http://www.howtoplaza.com/how-to-handle-mysql-errors-in-php/</guid>
		<description><![CDATA[In php sometimes when you execute MySQL commands the queries don&#8217;t execute well and you don&#8217;t even know unless you define some mechanism to trap the resulting MySQL error. For instance if you&#8217;re in setting a new record into MySQL table and if there is some column mismatched you won&#8217;t be able to know it [...]]]></description>
			<content:encoded><![CDATA[<p></p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.howtoplaza.com%2Fhow-to-handle-mysql-errors-in-php"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.howtoplaza.com%2Fhow-to-handle-mysql-errors-in-php&amp;source=howtoplaza&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>In php sometimes when you execute MySQL commands the queries don&#8217;t execute well and you don&#8217;t even know unless you define some mechanism to trap the resulting <strong>MySQL error</strong>. For instance if you&#8217;re in setting a new record into MySQL table and if there is some column mismatched you won&#8217;t be able to know it unless you specifically checked the database to see whether a record has been inserted or not. There is a way you can trap whether an error occurred and then take the appropriate steps. This is now you can see if an error has occurred (<em>please remember we are talking about php here so we will be using the php MySQL commands to manipulate MySQL tables</em>): </p>
<p class="code">&lt;?php    <br />if(mysql_errno()&gt;0)     <br />{     <br />&#160;&#160;&#160; // take care of the error.     <br />}     <br />?&gt; </p>
<p>The error descriptions of MySQL are not very helpful so along with seeing the error message you should also see the query in case it is being dynamically generated for instance an online form. In the example below we will use a simple query: </p>
<p class="code">&lt;?php    <br />&#160;&#160;&#160; $fname=$_POST['fname'];     <br />&#160;&#160;&#160; $lname=$_POST['lname'];     <br />&#160;&#160;&#160; $query=mysql_query(&quot;insert into mytable (first_name, last_name) values (&#8216;&quot; . $fname . &quot;&#8217;, &#8216;&quot; . $lname . &quot;&#8217;&quot;);     <br />&#160;&#160;&#160; if(mysql_error()&gt;0)     <br />&#160;&#160;&#160; {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; print mysql_error() . &quot;&lt;br&gt;&lt;br&gt;&quot;;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; print $query;     <br />&#160;&#160;&#160; }     <br />?&gt; </p>
<p>In the above example in case there is an error in the dynamically generated MySQL query it will not only print the error it will also print the dynamically generated query.</p>
<br /><span style='font-size:8pt;'>Technorati Tags: <a href="http://technorati.com/tag/php+errors" rel="tag">php errors</a>, <a href="http://technorati.com/tag/MySQL+errors" rel="tag"> MySQL errors</a></span><br />
<div style="float:right"><a href="http://www.google.com/reader/link?url=http://www.howtoplaza.com/how-to-handle-mysql-errors-in-php&title=How to handle MySQL errors in php&srcTitle=The How To Do Things Blog&srcURL=http://www.howtoplaza.com"target="_blank" rel=""><img border="0" src="http://www.howtoplaza.com/wp-content/plugins/wp-google-buzz/icon/10.png" style="opacity:1;filter:alpha(opacity=100)" onmouseover="this.style.opacity=0.8;this.filters.alpha.opacity=80" onmouseout="this.style.opacity=1;this.filters.alpha.opacity=100"/> </a></div>]]></content:encoded>
			<wfw:commentRss>http://www.howtoplaza.com/how-to-handle-mysql-errors-in-php/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
