<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>Webcodez - The database of web programming tutorials &#187; Insert Query</title>
	<atom:link href="http://www.webcodez.net/tag/insert-query/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webcodez.net</link>
	<description>Archive of tutorials on php,mysql,Javascript,html,css and other coding languages as well as code-snippets.</description>
	<lastBuildDate>Tue, 18 May 2010 16:43:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MySql Basics &#8211; Insert Data</title>
		<link>http://www.webcodez.net/php-mysql/mysql-basics-insert-data/</link>
		<comments>http://www.webcodez.net/php-mysql/mysql-basics-insert-data/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 11:20:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP & MySql]]></category>
		<category><![CDATA[basics]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[fundamentals]]></category>
		<category><![CDATA[Insert Data]]></category>
		<category><![CDATA[Insert Query]]></category>
		<category><![CDATA[MySql]]></category>
		<category><![CDATA[Query]]></category>

		<guid isPermaLink="false">http://www.webcodez.net/?p=155</guid>
		<description><![CDATA[To insert data into the database, mysql queries are used. There are multiple types of mysql queries. The one to put data into the database is the INSERT query. This one inserts a new row into the database which requires the fields of a row for that table to be given a value to.
A basic [...]]]></description>
			<content:encoded><![CDATA[<p>To insert data into the database, mysql queries are used. There are multiple types of mysql queries. The one to put data into the database is the INSERT query. This one inserts a new row into the database which requires the fields of a row for that table to be given a value to.</p>
<p>A basic mysql query structure:</p>
<pre name="code" class="php:nogutter">
mysql_query("...query here..");
</pre>
<p>A basic INSERT query:</p>
<pre name="code" class="php:nogutter">
mysql_query("INSERT INTO table_name (field1, field2) VALUES ('value1', 'value2') ");
</pre>
<p>We could again use the or die(mysql_error()) function to make it show the mysql error message when an error occurs.</p>
<p>So in the above example we made it insert a new row for the table &#8216;table_name&#8217;. For that row we gave field1 the value &#8216;value1&#8242; and field2 the value &#8216;value2&#8242;.</p>
<p>Let&#8217;s have a look at an example of a table containing all user accounts (=rows):</p>
<p>Example table &#8216;users&#8217;:</p>
<p>[TABLE=1]</p>
<p>We already got one row in the table of the database, one user account. To add another one to this table we need to set values for the fields (id, )username, password, email. The ID field usually is auto_increment and primairy key, which means it&#8217;s a unique key for each row and automaticly increases for each new row that&#8217;s added and so doesn&#8217;t need to be set by ourselves. The example query would look like this ( for this table called &#8216;users&#8217; ):</p>
<pre name="code" class="php:nogutter">
$new_user = mysql_query("INSERT INTO users (username, password, email) VALUES ('testuser', 'testpassword', 'test.email@hotmail.com') ");
</pre>
<p>You see we here create a new row using the INSERT query, for the table called &#8216;users&#8217;, giving the value &#8216;testuser&#8217; to the field &#8216;username&#8217;, &#8216;testpassword&#8217; to the field &#8216;passsword&#8217; and &#8216;test.email@hotmail.com&#8217; to the field &#8216;email&#8217; for the new row we create ( representing a new user in this case ).</p>
<p>Hope you learnt something, if you have any questions, feel free to ask.</p>
<p>Cheers,<br />
Admin.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webcodez.net/php-mysql/mysql-basics-insert-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
