<?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>Linux, MySQL, PhP, Perl... &#187; admin</title>
	<atom:link href="http://linux.bgsnow.com/author/admin/feed" rel="self" type="application/rss+xml" />
	<link>http://linux.bgsnow.com</link>
	<description></description>
	<lastBuildDate>Fri, 18 Jun 2010 16:30:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Input Validation</title>
		<link>http://linux.bgsnow.com/input-validation.php</link>
		<comments>http://linux.bgsnow.com/input-validation.php#comments</comments>
		<pubDate>Fri, 18 Jun 2010 16:30:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mysql]]></category>

		<guid isPermaLink="false">http://linux.bgsnow.com/?p=263</guid>
		<description><![CDATA[A simple PHP function for INPUT validation. function check_chars&#40;$variable,$what,$min_length, $max_length,$bad_chars&#41;&#123; if &#40;strlen&#40;$variable&#41; &#60; $min_length &#124;&#124; strlen&#40;$variable&#41; &#62; $max_length&#41; &#123; die&#40;&#34;$what is not the correct number of chars or is missing.&#34;&#41;; &#125; else if &#40;preg_match&#40;&#34;/$bad_chars/i&#34;, $variable&#41;&#41; &#123; die&#40;&#34;Incorrect chars in $what.&#34;&#41;; &#125; else &#123; echo &#34;Successful type constraint check for $what.&#60;br \&#62;&#34;; &#125; &#160; $variable= mysql_real_escape_string&#40;$variable&#41;; [...]]]></description>
			<content:encoded><![CDATA[<p>A simple PHP function for INPUT validation.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> check_chars<span style="color: #009900;">&#40;</span><span style="color: #000088;">$variable</span><span style="color: #339933;">,</span><span style="color: #000088;">$what</span><span style="color: #339933;">,</span><span style="color: #000088;">$min_length</span><span style="color: #339933;">,</span> <span style="color: #000088;">$max_length</span><span style="color: #339933;">,</span><span style="color: #000088;">$bad_chars</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$variable</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$min_length</span> <span style="color: #339933;">||</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$variable</span><span style="color: #009900;">&#41;</span>  <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$max_length</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$what</span> is not the correct number of chars or is missing.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/<span style="color: #006699; font-weight: bold;">$bad_chars</span>/i&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$variable</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Incorrect chars in <span style="color: #006699; font-weight: bold;">$what</span>.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Successful type constraint check for <span style="color: #006699; font-weight: bold;">$what</span>.&lt;br \&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000088;">$variable</span><span style="color: #339933;">=</span> <span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$variable</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//a good place to escape anything suspicious that might have left.</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$variable</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//example usage</span>
&nbsp;
check_chars<span style="color: #009900;">&#40;</span><span style="color: #000088;">$first_name</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'First name'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">25</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;[^a-z]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//names should be longer than 2 and less than 25 chars</span>
check_chars<span style="color: #009900;">&#40;</span><span style="color: #000088;">$middle_initial</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Middle name'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;[^a-z]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//we want only the first char from the name</span>
check_chars<span style="color: #009900;">&#40;</span><span style="color: #000088;">$address</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Address'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">100</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;[^a-z0-9-, ]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//this could be probably improved</span>
check_chars<span style="color: #009900;">&#40;</span><span style="color: #000088;">$city</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'City'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">25</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;[^s-zA-Z]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
check_chars<span style="color: #009900;">&#40;</span><span style="color: #000088;">$state</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'State'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;[^A-Z]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
check_chars<span style="color: #009900;">&#40;</span><span style="color: #000088;">$zip</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Zip'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;[^0-9]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>
]]></content:encoded>
			<wfw:commentRss>http://linux.bgsnow.com/input-validation.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getty Images Scam?</title>
		<link>http://linux.bgsnow.com/getty-images-scam.php</link>
		<comments>http://linux.bgsnow.com/getty-images-scam.php#comments</comments>
		<pubDate>Wed, 16 Jun 2010 11:50:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[getty images]]></category>
		<category><![CDATA[scam]]></category>

		<guid isPermaLink="false">http://linux.bgsnow.com/?p=258</guid>
		<description><![CDATA[Is Getty Images a scam? It seems so from most posts on the net and if you have problems with them read these: http://internetmadness.blogspot.com/2007/06/getty-images-are-trying-to-getty-me.html http://www.zyra.info/getstu.htm Whether Getty is a scam or not remains a question to all. Their claims don&#8217;t have legal basis and I don&#8217;t think they have ever successfully sued anyone.]]></description>
			<content:encoded><![CDATA[<p>Is Getty Images a scam? It seems so from most posts on the net and if you have problems with them read these:</p>
<p><a href="http://internetmadness.blogspot.com/2007/06/getty-images-are-trying-to-getty-me.html">http://internetmadness.blogspot.com/2007/06/getty-images-are-trying-to-getty-me.html</a></p>
<p><a href="http://www.zyra.info/getstu.htm">http://www.zyra.info/getstu.htm</a></p>
<p>Whether Getty is a scam or not remains a question to all. Their claims don&#8217;t have legal basis and I don&#8217;t think they have ever successfully sued anyone.</p>]]></content:encoded>
			<wfw:commentRss>http://linux.bgsnow.com/getty-images-scam.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Normalization</title>
		<link>http://linux.bgsnow.com/mysql-normalization.php</link>
		<comments>http://linux.bgsnow.com/mysql-normalization.php#comments</comments>
		<pubDate>Sat, 05 Jun 2010 19:42:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mysql]]></category>
		<category><![CDATA[database normalization]]></category>

		<guid isPermaLink="false">http://linux.bgsnow.com/?p=249</guid>
		<description><![CDATA[Database normalization prevents redundancy, inconsistency and data loss. It includes several steps as follows: 1. 1NF &#8211; First Normal Form states that all tuple values should be atomic. Atomic means that there should be only one useful piece of data for each attribute. The first step in database normalization is to determine the functional dependencies in the database. [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Database normalization</strong> prevents redundancy, inconsistency and data loss. It includes several steps as follows:</p>
<p>1. 1NF &#8211; First Normal Form states that all tuple values should be atomic. Atomic means that there should be only one useful piece of data for each attribute.</p>
<p>The first step in database normalization is to determine the <strong>functional dependencie</strong>s in the database. This means to find which values are determined by which.</p>
<p>2. Decomposition and <strong>Boyce/Codd Normal Form</strong></p>
<p>BCNF has only one requirement &#8211; every <strong>functional dependency</strong> must be functionally determined by either a <strong>candidate key*</strong>, or a <em>superset</em> of a candidate key( <strong>superkey)</strong>.</p>
<p>*A <strong>candidate key</strong> is a set of attributes that must be <em>unique</em> for each tuple and <em>irreducible</em> into a smaller key.</p>
<p>Example:</p>
<p>candidate_key -&gt; value</p>
<p>candidate_key2 -&gt; value2</p>
<p>&#8230;</p>
<p>5. <strong>5th Normal Form</strong> requires that each join dependency is satisfied by superkeys.</p>
<p>A <strong>join dependency</strong>(<strong>JD) </strong>is a set of projections on a relation which when joined reform the original relation.</p>]]></content:encoded>
			<wfw:commentRss>http://linux.bgsnow.com/mysql-normalization.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Relational Theory</title>
		<link>http://linux.bgsnow.com/relational-theory.php</link>
		<comments>http://linux.bgsnow.com/relational-theory.php#comments</comments>
		<pubDate>Mon, 24 May 2010 19:28:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mysql]]></category>

		<guid isPermaLink="false">http://linux.bgsnow.com/?p=246</guid>
		<description><![CDATA[The difference between relvar and relation: A relation is a value, filled with all the attribute and tuple values. On the other hand a relvar is a variable associated with some representation of a relation. The difference between a base relation and a view: Base relation is the original value while a view is deducted [...]]]></description>
			<content:encoded><![CDATA[<p>The difference between <strong>relvar</strong> and <strong>relation</strong>:</p>
<p>A relation is a value, filled with all the attribute and tuple values. On the other hand a relvar is a variable associated with some representation of a relation.</p>
<p>The difference between a <strong>base relation</strong> and a <strong>view</strong>:</p>
<p>Base relation is the original value while a view is deducted from it by a certain criteria (select statement).</p>]]></content:encoded>
			<wfw:commentRss>http://linux.bgsnow.com/relational-theory.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Text Files and MySQL databases</title>
		<link>http://linux.bgsnow.com/csv_mysql_database.php</link>
		<comments>http://linux.bgsnow.com/csv_mysql_database.php#comments</comments>
		<pubDate>Sun, 23 May 2010 19:06:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mysql]]></category>
		<category><![CDATA[csv]]></category>
		<category><![CDATA[INTO OUTFILE]]></category>
		<category><![CDATA[LOAD DATA]]></category>

		<guid isPermaLink="false">http://linux.bgsnow.com/?p=240</guid>
		<description><![CDATA[If for some strange reason you have to import CSV file directly into MySQL here is a good query to go: mysql&#62; LOAD DATA INFILE &#8216;file.csv&#8217; INTO TABLE table_name FIELDS TERMINATED BY &#8216;,&#8217; OPTIONALLY ENCLOSED BY &#8216;&#8221;&#8216; LINES TERMINATED BY &#8216;\r\n&#8217; (column1, column2); It gives you all the options such as how fields are terminated, [...]]]></description>
			<content:encoded><![CDATA[<p>If for some strange reason you have to import CSV file directly into MySQL here is a good query to go:</p>
<p>mysql&gt; LOAD DATA INFILE &#8216;file.csv&#8217; INTO TABLE table_name FIELDS TERMINATED BY &#8216;,&#8217; OPTIONALLY ENCLOSED BY &#8216;&#8221;&#8216; LINES TERMINATED BY &#8216;\r\n&#8217; (column1, column2);</p>
<p>It gives you all the options such as how fields are terminated, enclosed and so on. The above example is specific for a csv file created with a Windows Text Editor. (windows&#8230; haha)</p>
<p>Similarly, if you have to export a query into a text file here is how this can be done:</p>
<p>mysql&gt; SELECT column1, column2 INTO OUTFILE &#8216;file.csv&#8217; FIELDS TERMINATED BY &#8216;,&#8217; OPTIONALLY ENCLOSED BY &#8216;&#8221;&#8216;LINES TERMINATED BY &#8216;\r\n&#8217; FROM table_name;</p>]]></content:encoded>
			<wfw:commentRss>http://linux.bgsnow.com/csv_mysql_database.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Advanced MySQL Priveleges</title>
		<link>http://linux.bgsnow.com/advanced-mysql-priveleges.php</link>
		<comments>http://linux.bgsnow.com/advanced-mysql-priveleges.php#comments</comments>
		<pubDate>Sun, 23 May 2010 18:08:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mysql]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://linux.bgsnow.com/?p=230</guid>
		<description><![CDATA[MySQL privileges assignment is a complex process which allows you to set different privileges for an user for different tables/databases. However, this process is very often neglected and users are granted with all privileges for a whole database. If improper privileges are applied this can lead to a website being hacked via MySQL. This means [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL privileges assignment is a complex process which allows you to set different privileges for an user for different tables/databases. However, this process is very often neglected and users are granted with all privileges for a whole database.</p>
<p>If improper privileges are applied this can lead to a website being hacked via MySQL. This means that the attacker executes a MySQL query which either illegally retrieves, updates or inserts information.</p>
<p>Thus when you manually assign privileges make sure not to grant only the needed privileges to the corresponding tables. This is not always possible though since many popular web applications use just one user for everything.<br />
So here is the usual MySQL privileges granting:</p>
<p>GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX ON database.* TO user@localhost IDENTIFIED BY &#8216;password&#8217;;</p>
<p>This will grant all privileges to user@localhost. However, imagine that you can divide your script into parts with different functionality. For example, user_logs would be used to read just the logs from the &#8216;logs&#8217; table. Then his privileges should be:</p>
<p>GRANT SELECT ON database.logs TO user_logs@localhost IDENTIFIED BY &#8216;password&#8217;;</p>
<p>This will make sure that even compromised user_logs will not be able to mess with the entire database.<br />
MySQL privileges assignment is a complex process which allows you to set different privileges for an user for different tables/databases. However, this process is very often neglected and users are granted with all privileges for a whole database.</p>
<p>If improper privileges are applied this can lead to a website being hacked via MySQL. This means that the attacker executes a MySQL query which either illegally retrieves, updates or inserts information.</p>
<p>Thus when you manually assign privileges make sure not to grant only the needed privileges to the corresponding tables. This is not always possible though since many popular web applications use just one user for everything.</p>
<p>So here is the usual MySQL privileges granting:</p>
<p>GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX ON database.* TO user@localhost IDENTIFIED BY &#8216;password&#8217;;</p>
<p>This will grant all privileges to user@localhost. However, imagine that you can divide your script into parts with different functionality. For example, user_logs would be used to read just the logs from the &#8216;logs&#8217; table. Then his privileges should be:</p>
<p>GRANT SELECT ON database.logs TO user_logs@localhost IDENTIFIED BY &#8216;password&#8217;;</p>
<p>This will make sure that even compromised user_logs will not be able to mess with the entire database.</p>]]></content:encoded>
			<wfw:commentRss>http://linux.bgsnow.com/advanced-mysql-priveleges.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shopping Cart in PHP</title>
		<link>http://linux.bgsnow.com/shopping-cart-in-php.php</link>
		<comments>http://linux.bgsnow.com/shopping-cart-in-php.php#comments</comments>
		<pubDate>Thu, 13 May 2010 17:21:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Others]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[shopping cart]]></category>

		<guid isPermaLink="false">http://linux.bgsnow.com/?p=223</guid>
		<description><![CDATA[Here is part of my shopping cart project which I created during my PHP / MySQL studies. Needless to say it is good only for studying purposes because it is insecure and quite immature: The funniest thing is that one of the requirements for this cart was to be in just 2 files. So because [...]]]></description>
			<content:encoded><![CDATA[<p>Here is part of my shopping cart project which I created during my PHP / MySQL studies. Needless to say it is good only for studying purposes because it is insecure and quite immature:</p>
<p>The funniest thing is that one of the requirements for this cart was to be in just 2 files. So because I couldn&#8217;t imagine to fit it in two files I just fitted it in 2 <img src='http://linux.bgsnow.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Let the fun begin:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">go back to the store and begin shopping <span style="color: #339933;">:</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">';
&nbsp;
// If post input with '</span><span style="color: #b1b100;">do</span><span style="color: #0000ff;">' values is coming from the admin area forms we will process it here. This is because we have to use get otherwise the URL will become too long especially when we specify long description for products.
&nbsp;
switch ($_POST['</span><span style="color: #b1b100;">do</span><span style="color: #0000ff;">']) { 
&nbsp;
	case '</span>insert<span style="color: #0000ff;">':
		$command = &quot;insert into shop_products (prouct_name, price, product_image, description) values('</span><span style="color: #0000ff;">&quot;.addslashes(<span style="color: #006699; font-weight: bold;">$_POST</span>['product_name']).&quot;</span><span style="color: #0000ff;">','</span><span style="color: #0000ff;">&quot;.addslashes(<span style="color: #006699; font-weight: bold;">$_POST</span>['price']).&quot;</span><span style="color: #0000ff;">','</span><span style="color: #0000ff;">&quot;.addslashes(<span style="color: #006699; font-weight: bold;">$_POST</span>['product_image']).&quot;</span><span style="color: #0000ff;">','</span><span style="color: #0000ff;">&quot;.addslashes(<span style="color: #006699; font-weight: bold;">$_POST</span>['description']).&quot;</span><span style="color: #0000ff;">');&quot;;
		$result = mysql_query($command);
		print &quot;Data was successfully entered.
&quot;;
		mysql_close($db);
		exit();
		break;
&nbsp;
	case '</span>update<span style="color: #0000ff;">':
		$command = &quot;update shop_products set prouct_name='</span><span style="color: #0000ff;">&quot;.addslashes(<span style="color: #006699; font-weight: bold;">$_POST</span>['product_name']).&quot;</span><span style="color: #0000ff;">', price='</span><span style="color: #0000ff;">&quot;.addslashes(<span style="color: #006699; font-weight: bold;">$_POST</span>['price']).&quot;</span><span style="color: #0000ff;">', product_image='</span><span style="color: #0000ff;">&quot;.addslashes(<span style="color: #006699; font-weight: bold;">$_POST</span>['product_image']).&quot;</span><span style="color: #0000ff;">', description='</span><span style="color: #0000ff;">&quot;.addslashes(<span style="color: #006699; font-weight: bold;">$_POST</span>['description']).&quot;</span><span style="color: #0000ff;">' where product_id='</span><span style="color: #0000ff;">&quot;.<span style="color: #006699; font-weight: bold;">$_POST</span>['product'].&quot;</span><span style="color: #0000ff;">';&quot;;
		$result = mysql_query($command);
		print &quot;Data was successfully updated.
&quot;;
		mysql_close($db);
		exit();
		break;
}
&nbsp;
//Since we are limited to the number of pages we will use switch to simulate all the pages we want :)
&lt;span id=&quot;more-223&quot;&gt;&lt;/span&gt;
switch ($_GET['</span>page<span style="color: #0000ff;">']) {
&nbsp;
/* #################################################
 * #                  Checkout                     #
 * ################################################# */
&nbsp;
//Our checkout page
    case '</span>checkout<span style="color: #0000ff;">':
        if (!$_SESSION['</span>logged<span style="color: #0000ff;">']) {
&nbsp;
	echo '</span>Attention<span style="color: #339933;">:</span> You have to be registered and logged in in order to check out<span style="color: #339933;">.</span>
&nbsp;
<span style="color: #0000ff;">';
	echo &quot;Please &lt;a href=&quot;index.php?page=registration_form&quot;&gt; register &lt;/a&gt; or &lt;a href=&quot;index.php?page=login&quot;&gt;log in&lt;/a&gt; first.&quot;;
	exit();
}
&nbsp;
if ($_SESSION['</span>cart<span style="color: #0000ff;">']) {
&nbsp;
//this is the total price
$total = 0;
&nbsp;
function subtotal($price,$quantity) {
	$subtotal = ($price*$quantity) + ($price*$quantity*$tax); //multiplied by quantity and tax
	return $subtotal;
	}
&nbsp;
echo &quot;Your cart contains:&quot;;
&nbsp;
$purchase = '</span><span style="color: #0000ff;">';
&nbsp;
while (list($key, $value) = each($_SESSION['</span>cart<span style="color: #0000ff;">'])) {
&nbsp;
	//Get the price of each product
	$products_query = mysql_query(&quot;select product_id,price from shop_products where prouct_name = '</span><span style="color: #000088;">$key</span><span style="color: #0000ff;">';&quot;);
	$products = mysql_fetch_object($products_query);
&nbsp;
    echo &quot;
 $value pounds $key at the price $&quot;.$products-&amp;gt;price.&quot;.&quot;;
    $subtotal = subtotal($products-&amp;gt;price,$value);
    echo &quot; Subtotal: $ $subtotal&quot;;
    $total += $subtotal;
&nbsp;
    //Here we will insert it into the database
    $command = &quot;insert into shop_purchases (date, user_id, product_id, quantity) values(curdate(),&quot;.$_SESSION['</span>user_id<span style="color: #0000ff;">'].&quot;,$products-&amp;gt;product_id,'</span><span style="color: #000088;">$value</span><span style="color: #0000ff;">');&quot;;
	$result = mysql_query($command);
&nbsp;
    //We will also add a description for the paypal purchase
    $purchase .= $key.'</span> x <span style="color: #0000ff;">'.$value;
    $purchase .= '</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #0000ff;">';
&nbsp;
}
&nbsp;
$tax=0.08;
$total += $total*$tax;
echo '</span>
&nbsp;
Total with TAX<span style="color: #339933;">:</span> $<span style="color: #0000ff;">'.$total;
echo '</span>
Purchase recorded in the database<span style="color: #339933;">.</span> Please proceed with the payment<span style="color: #0000ff;">';
&nbsp;
//We will just add the email for the customer in case he pays with different paypal account
//All the time we have used the email as indicator for the user being logged in
//After that we can look up the address for that email from shadow.php
$purchase .= '</span>customer <span style="color: #339933;">=</span> <span style="color: #0000ff;">'.$_SESSION['</span>logged<span style="color: #0000ff;">'];
&nbsp;
//At this time only PayPal checkout is available
echo &quot;
&nbsp;
Check out with Paypal:&quot;;
&nbsp;
echo &amp;lt;&amp;lt;
&lt;form action=&quot;https://www.paypal.com/cgi-bin/webscr&quot; method=&quot;post&quot;&gt;
&lt;input name=&quot;cmd&quot; type=&quot;hidden&quot; value=&quot;_xclick&quot; /&gt;
&lt;input name=&quot;business&quot; type=&quot;hidden&quot; value=&quot;pi4a@pi4a.com&quot; /&gt;
&lt;input name=&quot;item_name&quot; type=&quot;hidden&quot; value=&quot;$purchase&quot; /&gt;
&lt;input name=&quot;item_number&quot; type=&quot;hidden&quot; /&gt;
&lt;input name=&quot;amount&quot; type=&quot;hidden&quot; value=&quot;$total&quot; /&gt;
&lt;input name=&quot;no_note&quot; type=&quot;hidden&quot; value=&quot;1&quot; /&gt;
&lt;input name=&quot;currency_code&quot; type=&quot;hidden&quot; value=&quot;USD&quot; /&gt;
&lt;input name=&quot;bn&quot; type=&quot;hidden&quot; value=&quot;PP-BuyNowBF&quot; /&gt;
&lt;input alt=&quot;Make payments with PayPal - it'</span>s fast<span style="color: #339933;">,</span> free and secure<span style="color: #339933;">!</span><span style="color: #0000ff;">&quot; name=&quot;</span>submit<span style="color: #0000ff;">&quot; src=&quot;</span>https<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.paypal.com/en_US/i/btn/x-click-but23.gif&quot; type=&quot;image&quot; /&gt;</span>
<span style="color: #339933;">&lt;/</span>form<span style="color: #339933;">&gt;</span>
&nbsp;
PAYPAL<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Your cart is empty so there is nothing to check out.'</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$begin_shopping</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* #################################################
 * #                  Logout                       #
 * ################################################# */</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// A simple log out function</span>
&nbsp;
    <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'logout'</span><span style="color: #339933;">:</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'You are now logged out'</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'logged'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'admin'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* #################################################
 * #                  View cart                    #
 * ################################################# */</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Our cart</span>
&nbsp;
    <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'cart'</span><span style="color: #339933;">:</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//The standard extract to remove $_GET from the Get variables</span>
<span style="color: #666666; font-style: italic;">//I have not used it for all scripts because it will be too obfuscating at times</span>
<span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #339933;">,</span> EXTR_PREFIX_SAME<span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;get&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//2 functions to cut off code</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// this function will show what the cart contains</span>
<span style="color: #000000; font-weight: bold;">function</span> cart_contains<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Your cart contains now:
&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">each</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cart'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$key</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">.</span><span style="color: #000088;">$value</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' pound(s)
'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> add_to_cart<span style="color: #009900;">&#40;</span><span style="color: #000088;">$product</span><span style="color: #339933;">,</span><span style="color: #000088;">$pounds</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
 <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cart'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$product</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+=</span> <span style="color: #000088;">$pounds</span><span style="color: #339933;">;</span>
 <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;You have added <span style="color: #006699; font-weight: bold;">$pounds</span> pounds <span style="color: #006699; font-weight: bold;">$product</span> to your cart.
&quot;</span><span style="color: #339933;">;</span>
 <span style="color: #b1b100;">return</span> <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cart'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//we define 4 cases depending on the availability of sessions and product variables</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cart'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$product</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Your cart is empty.'</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$begin_shopping</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cart'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$product</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cart'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	add_to_cart<span style="color: #009900;">&#40;</span><span style="color: #000088;">$product</span><span style="color: #339933;">,</span><span style="color: #000088;">$pounds</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	cart_contains<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cart'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$product</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	cart_contains<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	add_to_cart<span style="color: #009900;">&#40;</span><span style="color: #000088;">$product</span><span style="color: #339933;">,</span><span style="color: #000088;">$pounds</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	cart_contains<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* #################################################
 * #                  Login                        #
 * ################################################# */</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// A login page</span>
&nbsp;
		<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'login'</span><span style="color: #339933;">:</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'logged'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'You are logged in with email: '</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'logged'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'logged'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//We will have to use GET even for the login page in order to set page=login with a hidden value later</span>
<span style="color: #666666; font-style: italic;">//I know it is very insecure and POST should be used instead</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;&amp;</span>lt<span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;</span>form<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;page&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;hidden&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;login&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>table<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tbody<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td align<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;left&quot;</span><span style="color: #339933;">&gt;</span>
Email<span style="color: #339933;">:</span> <span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;email&quot;</span> size<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;25&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td align<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;left&quot;</span><span style="color: #339933;">&gt;</span>
Pass<span style="color: #339933;">:</span> <span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;password&quot;</span> size<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;25&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;password&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td align<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;left&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;SUBMIT&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>tbody<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>table<span style="color: #339933;">&gt;</span>
FORM<span style="color: #339933;">;</span>
<span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #339933;">,</span> EXTR_PREFIX_SAME<span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;get&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$users</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;select user_id, email, password from shop_users where email = '<span style="color: #006699; font-weight: bold;">$email</span>'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$users</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//First I make sure there is a $_GET['email']. Otherwise there is a bug which validates emtpy logins.</span>
<span style="color: #666666; font-style: italic;">//Then I compare for equality the two strings for email and password</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$email</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #000088;">$email</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$data</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>email <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #000088;">$password</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$data</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>password<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;You have successfully logged in.&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'logged'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span> <span style="color: #000088;">$email</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user_id'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$data</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>user_id<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//A check to see if the logged in user is admin</span>
<span style="color: #666666; font-style: italic;">//The admin is the user with user_id = 1. This makes sense because the first user to register should be the admin.</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>user_id <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'admin'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
 	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;You are an admin user. Please refresh to see the admin menu&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>                
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">//If it reaches this point die with an error</span>
<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Incorrect login!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* #################################################
 * #                Registration                   #
 * ################################################# */</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Registration form </span>
&nbsp;
        <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'registration_form'</span><span style="color: #339933;">:</span>
?<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;</span>table<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tbody<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td colspan<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;2&quot;</span> align<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;left&quot;</span><span style="color: #339933;">&gt;&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td align<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;right&quot;</span><span style="color: #339933;">&gt;</span>
Name<span style="color: #339933;">:&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;name&quot;</span> size<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;25&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&amp;lt;? echo <span style="color: #006699; font-weight: bold;">$_GET</span>['name']; ?&amp;gt;&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td align<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;right&quot;</span><span style="color: #339933;">&gt;</span>
Email<span style="color: #339933;">:&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td align<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;left&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;email&quot;</span> size<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;25&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&amp;lt;? echo <span style="color: #006699; font-weight: bold;">$_GET</span>['email']; ?&amp;gt;&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td align<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;right&quot;</span><span style="color: #339933;">&gt;</span>
Address<span style="color: #339933;">:&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td align<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;left&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;address&quot;</span> size<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;25&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&amp;lt;? echo <span style="color: #006699; font-weight: bold;">$_GET</span>['address']; ?&amp;gt;&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td colspan<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;2&quot;</span> align<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;left&quot;</span><span style="color: #339933;">&gt;</span>
How did you hear about us?
<span style="color: #339933;">&lt;</span>ul<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;found&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;radio&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;wordofmouth&quot;</span> <span style="color: #339933;">/&gt;</span>Word of Mouth
&nbsp;
<span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;found&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;radio&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;search&quot;</span> <span style="color: #339933;">/&gt;</span>Online Search
&nbsp;
<span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;found&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;radio&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;article&quot;</span> <span style="color: #339933;">/&gt;</span>Printed publication<span style="color: #339933;">/</span>article
&nbsp;
<span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;found&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;radio&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;other&quot;</span> <span style="color: #339933;">/&gt;</span>Other<span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td colspan<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;2&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>input checked<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;checked&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;spam&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;checkbox&quot;</span> <span style="color: #339933;">/&gt;</span>Please email me all kinds of stuff<span style="color: #339933;">.&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td colspan<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;2&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;tos&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;checkbox&quot;</span> <span style="color: #339933;">/&gt;</span>I have read and accept Terms of service<span style="color: #339933;">.&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td colspan<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;2&quot;</span> align<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;center&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;SUBMIT&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>tbody<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>table<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>form<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>table<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tbody<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td<span style="color: #339933;">&gt;</span>Product name<span style="color: #339933;">:&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;product_name&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td<span style="color: #339933;">&gt;</span>Price<span style="color: #339933;">:&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td<span style="color: #339933;">&gt;&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;price&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td<span style="color: #339933;">&gt;</span>Image URL<span style="color: #339933;">:&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;product_image&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td<span style="color: #339933;">&gt;</span>Description<span style="color: #339933;">:&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>textarea cols<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;40&quot;</span> rows<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;6&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;description&quot;</span><span style="color: #339933;">&gt;&lt;/</span>textarea<span style="color: #339933;">&gt;&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>tbody<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>table<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;do&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;hidden&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;insert&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> <span style="color: #339933;">/&gt;</span>
&nbsp;
ADD_PRODUCT_FORM<span style="color: #339933;">;</span>
<span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'action'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'delete'</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'product'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #000088;">$product_id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'product'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;delete from shop_products where product_id = '<span style="color: #006699; font-weight: bold;">$product_id</span>' limit 1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">exit</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Selected product deleted from cart&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'action'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'modify'</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'product'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Here is the page for the modification of product</span>
<span style="color: #000088;">$query</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;select prouct_name, price, product_image, description from shop_products where product_id='&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'product'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;';&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$modify</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$modification</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$modify</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$product</span><span style="color: #339933;">=</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'product'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;&amp;</span>lt<span style="color: #339933;">;&lt;</span>form action<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;index.php&quot;</span> method<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>table<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tbody<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td<span style="color: #339933;">&gt;</span>Product name<span style="color: #339933;">:&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;product_name&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$modification</span>-&amp;gt;prouct_name&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td<span style="color: #339933;">&gt;</span>Price<span style="color: #339933;">:&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td<span style="color: #339933;">&gt;&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;price&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$modification</span>-&amp;gt;price&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td<span style="color: #339933;">&gt;</span>Image URL<span style="color: #339933;">:&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;product_image&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$modification</span>-&amp;gt;product_image&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td<span style="color: #339933;">&gt;</span>Description<span style="color: #339933;">:&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>textarea cols<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;40&quot;</span> rows<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;6&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;description&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000088;">$modification</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>description<span style="color: #339933;">&lt;/</span>textarea<span style="color: #339933;">&gt;&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>tbody<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>table<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;do&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;hidden&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;update&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;product&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;hidden&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$product</span>&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>form<span style="color: #339933;">&gt;</span>
&nbsp;
MODIFY_PRODUCT_FORM<span style="color: #339933;">;</span>
<span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//This is the default sub-case when we get all the products listed</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;
&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;
&nbsp;
&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'select * from shop_products'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;
&nbsp;
<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;
&lt;table border=&quot;</span><span style="color: #cc66cc;">1</span><span style="color: #0000ff;">&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th&gt;product name&lt;/th&gt;
&lt;th&gt;price&lt;/th&gt;
&lt;th&gt;image_url&lt;/th&gt;
&lt;th&gt;description&lt;/th&gt;
&lt;th&gt;modify&lt;/th&gt;
&lt;th&gt;delete&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$data</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>prouct_name<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/td&gt;
&lt;td&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$data</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>price<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/td&gt;
&lt;td&gt;&quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$data</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>product_image<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/td&gt;
&lt;td&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$data</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>description<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/td&gt;
&lt;td&gt; &lt;a href=&quot;</span>index<span style="color: #339933;">.</span>php?page<span style="color: #339933;">=</span>admin<span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>action<span style="color: #339933;">=</span>modify<span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>product<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&gt;product_id.&quot;</span><span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span>V<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;index.php?page=admin&amp;amp;action=delete&amp;amp;product=&quot;</span><span style="color: #339933;">&gt;</span>product_id<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&amp;gt;X&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;a href=&quot;</span>index<span style="color: #339933;">.</span>php?page<span style="color: #339933;">=</span>admin<span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>action<span style="color: #339933;">=</span>add_product<span style="color: #0000ff;">&quot;&gt;Add a new product&lt;/a&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Sorry. No access'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* #################################################
 * #   Admin Page - View customers                 #
 * ################################################# */</span>    
&nbsp;
        <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'view_customers'</span><span style="color: #339933;">:</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//a check to make sure this is admin</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'admin'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Customers
&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;
&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;
&nbsp;
&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'select * from shop_users'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;
&nbsp;
<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;
&lt;table border=&quot;</span><span style="color: #cc66cc;">1</span><span style="color: #0000ff;">&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th&gt;email&lt;/th&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;th&gt;password&lt;/th&gt;
&lt;th&gt;reference&lt;/th&gt;
&lt;th&gt;address&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$data</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>email<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/td&gt;
&lt;td&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$data</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>name<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/td&gt;
&lt;td&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$data</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>password<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/td&gt;
&lt;td&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$data</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>reference<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/td&gt;
&lt;td&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$data</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>address<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Sorry. No access'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* #################################################
 * #   Admin Page - View purchases                 #
 * ################################################# */</span>    
&nbsp;
        <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'view_purchases'</span><span style="color: #339933;">:</span>
<span style="color: #666666; font-style: italic;">//a check to make sure this is admin</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'admin'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Purchases
&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;
&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;
&nbsp;
&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;select sp.date, group_concat(concat(spr.prouct_name,' ', sp.quantity, ' pounds') separator ', ') as purchases, su.name from (shop_purchases as sp left join shop_users as su on sp.user_id = su.user_id) left join shop_products as spr on sp.product_id=spr.product_id group by name;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;
&nbsp;
<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;
&lt;table border=&quot;</span><span style="color: #cc66cc;">1</span><span style="color: #0000ff;">&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th&gt;date&lt;/th&gt;
&lt;th&gt;purchases&lt;/th&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$data</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>date<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/td&gt;
&lt;td&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$data</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>purchases<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/td&gt;
&lt;td&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$data</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>name<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Sorry. No access'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>       
&nbsp;
<span style="color: #666666; font-style: italic;">/* #################################################
 * #                  Default Index                #
 * ################################################# */</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//The default index</span>
&nbsp;
        <span style="color: #b1b100;">default</span><span style="color: #339933;">:</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'
&lt;h2&gt;Our hot offers include:&lt;/h2&gt;
'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'
'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$products</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;select * from shop_products&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$products</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'
&nbsp;
'</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'
&nbsp;
FORM;
}
&nbsp;
echo '</span>
<span style="color: #339933;">&lt;</span>table<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tbody<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td<span style="color: #339933;">&gt;&lt;</span>img src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;'.<span style="color: #006699; font-weight: bold;">$data</span>-&amp;gt;product_image.'&quot;</span> alt<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #339933;">/&gt;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td<span style="color: #339933;">&gt;</span><span style="color: #0000ff;">'.&quot;$data-&amp;gt;prouct_name - &quot;.$data-&amp;gt;description;
    echo &quot;
&nbsp;
&quot;.&quot;Price: $&quot;.$data-&amp;gt;price.'</span> per pound<span style="color: #0000ff;">';
&nbsp;
//In the form I will add a hidden value page = cart so that it goes to the cart case
&nbsp;
echo &amp;lt;&amp;lt;
&lt;form&gt;
Pounds: &lt;input maxlength=&quot;3&quot; name=&quot;pounds&quot; size=&quot;2&quot; type=&quot;text&quot; value=&quot;1&quot; /&gt;
&lt;input name=&quot;product&quot; type=&quot;hidden&quot; value=&quot;$data-&amp;gt;prouct_name&quot; /&gt;
&lt;input name=&quot;page&quot; type=&quot;hidden&quot; value=&quot;cart&quot; /&gt;
&lt;input type=&quot;submit&quot; value=&quot;Get&quot; /&gt;
&lt;/form&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
'</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #990000;">mysql_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$db</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
?<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span></pre></div></div>
]]></content:encoded>
			<wfw:commentRss>http://linux.bgsnow.com/shopping-cart-in-php.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eclipse in ZenWalk</title>
		<link>http://linux.bgsnow.com/eclipse-in-zenwalk.php</link>
		<comments>http://linux.bgsnow.com/eclipse-in-zenwalk.php#comments</comments>
		<pubDate>Thu, 24 Dec 2009 10:16:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jre]]></category>
		<category><![CDATA[zenwalk]]></category>

		<guid isPermaLink="false">http://linux.bgsnow.com/?p=208</guid>
		<description><![CDATA[If you try a default install of Eclipse in Zenwalk you will probably get an error about Eclipse not being able to find java&#8217;s path: A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No Java virtual machine was found after searching the following locations: /usr/lib/eclipse-3.4.1/jre/bin/java [...]]]></description>
			<content:encoded><![CDATA[<p>If you try a default install of Eclipse in Zenwalk you will probably get an error about Eclipse not being able to find java&#8217;s path:</p>
<p><em>A Java Runtime Environment (JRE) or Java Development Kit (JDK)</em><br />
<em>must be available in order to run Eclipse. No Java virtual machine</em></p>
<p><em>was found after searching the following locations:</em></p>
<p><em>/usr/lib/eclipse-3.4.1/jre/bin/java</em></p>
<p><em>java in your current PATH</em></p>
<p><em>A Java Runtime Environment (JRE) or Java Development Kit (JDK)must be available in order to run Eclipse. No Java virtual machinewas found after searching the following locations:/usr/lib/eclipse-3.4.1/jre/bin/javajava in your current PATH</em></p>
<p>Of course, you will have to install JRE (or JDE) first. For this purpose simply use netpkg to install &#8216;jre&#8217;. However, this will not help and you will have to add the following symlink:</p>
<p><em># ln -s /usr/lib/java/ /usr/lib/eclipse-3.4.1/jre</em></p>
<p>After that Eclipse will be working perfectly fine on your Zenwalk <img src='http://linux.bgsnow.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>]]></content:encoded>
			<wfw:commentRss>http://linux.bgsnow.com/eclipse-in-zenwalk.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Imagemagick libfftw3.so.3 error</title>
		<link>http://linux.bgsnow.com/imagemagick-libfftw3-so-3-error.php</link>
		<comments>http://linux.bgsnow.com/imagemagick-libfftw3-so-3-error.php#comments</comments>
		<pubDate>Tue, 01 Dec 2009 14:38:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[fftw]]></category>
		<category><![CDATA[imagemagick]]></category>
		<category><![CDATA[libfftw3.so.3]]></category>
		<category><![CDATA[zenwalk]]></category>

		<guid isPermaLink="false">http://linux.bgsnow.com/?p=199</guid>
		<description><![CDATA[If you have tried to run (install) Imagemagick on ZenWalk 6.2 (possibly on other distros too) you might have run into problems with libfftw3.so.3 such as: $ convert convert: error while loading shared libraries: libfftw3.so.3: cannot open shared object file: No such file or directory In order to fix this error simply install fftw (with [...]]]></description>
			<content:encoded><![CDATA[<p>If you have tried to run (install) Imagemagick on ZenWalk 6.2 (possibly on other distros too) you might have run into problems with libfftw3.so.3 such as:</p>
<p>$ convert<br />
convert: error while loading shared libraries: libfftw3.so.3: cannot open shared object file: No such file or directory</p>
<p>In order to fix this error simply install fftw (with netpkg presumably):</p>
<p>Successfully installed:<br />
fftw-3.2.2-i686-62.1.txz</p>
<p>After that convert (one of Imagemagick binaries) will work perfectly fine:</p>
<p>$ convert &#8211;version<br />
Version: ImageMagick 6.5.4-9 2009-08-09 Q16 OpenMP <a href="http://www.imagemagick.org" rel="nofollow">http://www.imagemagick.org</a><br />
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC</p>]]></content:encoded>
			<wfw:commentRss>http://linux.bgsnow.com/imagemagick-libfftw3-so-3-error.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Starting MySQL. ERROR! Manager of pid-file quit without updating file.</title>
		<link>http://linux.bgsnow.com/starting-mysql-error-manager-of-pid-file-quit-without-updating-file.php</link>
		<comments>http://linux.bgsnow.com/starting-mysql-error-manager-of-pid-file-quit-without-updating-file.php#comments</comments>
		<pubDate>Sat, 14 Nov 2009 21:11:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Others]]></category>
		<category><![CDATA[/var/lib/mysql]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[pid-file]]></category>

		<guid isPermaLink="false">http://linux.bgsnow.com/?p=195</guid>
		<description><![CDATA[I got that nasty error after moving around different directories in /var/lib/mysql: root@server:/var/lib/mysql# /etc/init.d/mysql start Starting MySQL. ERROR! Manager of pid-file quit without updating file. There were all kind of suggestions about it on the net, most of which had something to do with incorrect shutdown or incorrect permissions for the pid file. One of [...]]]></description>
			<content:encoded><![CDATA[<p>I got that nasty error after moving around different directories in /var/lib/mysql:</p>
<p><span style="color: #808080;">root@server:/var/lib/mysql# /etc/init.d/mysql start</span></p>
<p><span style="color: #808080;">Starting MySQL. ERROR! Manager of pid-file quit without updating file.</span></p>
<p>There were all kind of suggestions about it on the net, most of which had something to do with incorrect shutdown or incorrect permissions for the pid file.</p>
<p>One of the suggestions reminded me to read the mysql error log <img src='http://linux.bgsnow.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Here is what the error log said:</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">root@server:/var/lib/mysql# /etc/init.d/mysql start</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Starting MySQL. ERROR! Manager of pid-file quit without updating file.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">root@server:/var/lib/mysql# mysql</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">mysql                       mysql_config                mysqldumpslow               mysql_idle_processes.pm     mysqlshow                   mysql_tzinfo_to_sql</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">mysqlaccess                 mysql_convert_table_format  mysql_explain_log           mysqlimport                 mysql_sock.pm               mysql_upgrade</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">mysqladmin                  mysqld                      mysql_find_rows             mysql_install_db            mysql_tableinfo             mysql_upgrade_shell</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">mysqlbinlog                 mysqld-debug                mysql_fix_extensions        mysql_logs.sh               mysqltest                   mysql_waitpid</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">mysqlbug                    mysqld_multi                mysql_fix_privilege_tables  mysqlmanager                mysqltestmanager            mysql_zap</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">mysqlcheck                  mysqld_safe                 mysqlhotcopy                mysql_secure_installation   mysqltestmanagerc</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">mysql_client_test           mysqldump                   mysqlhotcopy.orig           mysql_setpermission         mysqltestmanager-pwgen</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">root@server:/var/lib/mysql# mysqld</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">mysqld         mysqld-debug   mysqld_multi   mysqld_safe    mysqldump      mysqldumpslow</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">root@server:/var/lib/mysql# mysqld</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">mysqld         mysqld-debug   mysqld_multi   mysqld_safe    mysqldump      mysqldumpslow</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">root@server:/var/lib/mysql# mysqld_safe start</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Starting mysqld daemon with databases from /var/lib/mysql</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">STOPPING server from pid file /var/lib/mysql/host.server.bgsnow.com.pid</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">091114 13:14:56  mysqld ended</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">root@server:/var/lib/mysql# ll /var/lib/mysql/host.server.bgsnow.com.p</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">root@server:/var/lib/mysql# touch /var/lib/mysql/host.server.bgsnow.com.pid</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">root@server:/var/lib/mysql# chown mysql: /var/lib/mysql/host.server.bgsnow.com.pid</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">root@server:/var/lib/mysql# /etc/init.d/mysql start</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Starting MySQL. ERROR! Manager of pid-file quit without updating file.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">root@server:/var/lib/mysql# tail -f /var/lib/mysql</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">mysql/    mysqlA/   mysqlOLD/</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">root@server:/var/lib/mysql# tail -f /var/lib/mysql/mysql-slow.log</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">host.server.bgsnow.com.err  ib_logfile0                mysql-slow.log             optistr2_optistreams/</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">ibdata1                    ib_logfile1                optistr2_opti/             optistr2_perldesk/</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">root@server:/var/lib/mysql# tail -f /var/lib/mysql/host.server.bgsnow.com.err</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">InnoDB: Restoring possible half-written data pages from the doublewrite</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">InnoDB: buffer&#8230;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">InnoDB: Doing recovery: scanned up to log sequence number 0 43655</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">091114 13:16:20  InnoDB: Starting an apply batch of log records to the database&#8230;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">InnoDB: Progress in percents: 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">InnoDB: Apply batch completed</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">091114 13:16:21  InnoDB: Started; log sequence number 0 43655</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">091114 13:16:21 [ERROR] Fatal error: Can&#8217;t open and lock privilege tables: Table &#8216;mysql.host&#8217; doesn&#8217;t exist</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">091114 13:16:21  mysqld ended</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">091114 13:16:52  mysqld started</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">InnoDB: Log scan progressed past the checkpoint lsn 0 36808</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">091114 13:16:52  InnoDB: Database was not shut down normally!</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">InnoDB: Starting crash recovery.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">InnoDB: Reading tablespace information from the .ibd files&#8230;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">InnoDB: Restoring possible half-written data pages from the doublewrite</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">InnoDB: buffer&#8230;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">InnoDB: Doing recovery: scanned up to log sequence number 0 43655</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">091114 13:16:52  InnoDB: Starting an apply batch of log records to the database&#8230;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">InnoDB: Progress in percents: 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">InnoDB: Apply batch completed</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">091114 13:16:53  InnoDB: Started; log sequence number 0 43655</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">091114 13:16:53 [ERROR] Fatal error: Can&#8217;t open and lock privilege tables: Table &#8216;mysql.host&#8217; doesn&#8217;t exist</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">091114 13:16:53  mysqld ended</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">root@server:/var/lib/mysql# ls</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">./  ../  host.server.bgsnow.com.err  ibdata1  ib_logfile0  ib_logfile1  mysql-slow.log  optistr2_opti/  optistr2_optistreams/  optistr2_perldesk/</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">root@server:/var/lib/mysql# ll ../</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">alternatives/     dhclient/         logrotate.status  mlocate/          mysqlA/           pgsql/            rkhunter/         sepolgen/         stateless/        yum/</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">dbus/             games/            misc/             mysql/            mysqlOLD/         random-seed       rpm/              spamassassin/     texmf/</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">root@server:/var/lib/mysql# ll ../</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">alternatives/     dhclient/         logrotate.status  mlocate/          mysqlA/           pgsql/            rkhunter/         sepolgen/         stateless/        yum/</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">dbus/             games/            misc/             mysql/            mysqlOLD/         random-seed       rpm/              spamassassin/     texmf/</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">root@server:/var/lib/mysql# ll ../mysqlOLD/</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">cphulkd/                   host.server.bgsnow.com.err  ib_logfile0                mysql/                     roundcube/                 sentry_stat/</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">eximstats/                 host.server.bgsnow.com.pid  ib_logfile1                mysql-slow.log             sentry/                    sentry_traf/</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">horde/                     ibdata1                    leechprotect/              mysql.sock                 sentry_mambo/              test/</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">root@server:/var/lib/mysql# ll ../mysqlOLD/*</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">root@server:/var/lib/mysql# ls</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">./  ../  host.server.bgsnow.com.err  ibdata1  ib_logfile0  ib_logfile1  mysql-slow.log  optistr2_opti/  optistr2_optistreams/  optistr2_perldesk/</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">root@server:/var/lib/mysql# mv ../mysqlOLD/</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">cphulkd/                   host.server.bgsnow.com.err  ib_logfile0                mysql/                     roundcube/                 sentry_stat/</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">eximstats/                 host.server.bgsnow.com.pid  ib_logfile1                mysql-slow.log             sentry/                    sentry_traf/</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">horde/                     ibdata1                    leechprotect/              mysql.sock                 sentry_mambo/              test/</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">root@server:/var/lib/mysql# mv ../mysqlOLD/* ./</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">mv: overwrite `./host.server.bgsnow.com.err&#8217;? y</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">mv: overwrite `./ibdata1&#8242;? n</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">mv: overwrite `./ib_logfile0&#8242;? n</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">mv: overwrite `./ib_logfile1&#8242;? n</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">mv: overwrite `./mysql-slow.log&#8217;? y</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">root@server:/var/lib/mysql# /etc/init.d/mysql restart</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Shutting down MySQL. SUCCESS!</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Starting MySQL. SUCCESS!</div>
<p><span style="color: #808080;">root@server:/var/lib/mysql# tail -f /var/lib/mysql/host.server.bgsnow.com.err </span></p>
<p><span style="color: #808080;">InnoDB: Restoring possible half-written data pages from the doublewrite</span></p>
<p><span style="color: #808080;">InnoDB: buffer&#8230;</span></p>
<p><span style="color: #808080;">InnoDB: Doing recovery: scanned up to log sequence number 0 43655</span></p>
<p><span style="color: #808080;">091114 13:16:20  InnoDB: Starting an apply batch of log records to the database&#8230;</span></p>
<p><span style="color: #808080;">InnoDB: Progress in percents: 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 </span></p>
<p><span style="color: #808080;">InnoDB: Apply batch completed</span></p>
<p><span style="color: #808080;">091114 13:16:21  InnoDB: Started; log sequence number 0 43655</span></p>
<p><span style="color: #808080;">091114 13:16:21 [ERROR] Fatal error: Can&#8217;t open and lock privilege tables: Table &#8216;mysql.host&#8217; doesn&#8217;t exist</span></p>
<p><span style="color: #808080;">091114 13:16:21  mysqld ended</span></p>
<p>Obviously I have forgotten to move back the mysql directory which is responsible for the database for all privileges, databases and so on <img src='http://linux.bgsnow.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   So moving it back along with the rest of the core files solved the problem:</p>
<p><span style="color: #808080;">root@server:/var/lib/mysql# mv ../mysqlOLD/* ./</span></p>
<p><span style="color: #808080;">mv: overwrite `./host.server.bgsnow.com.err&#8217;? y</span></p>
<p><span style="color: #808080;">mv: overwrite `./ibdata1&#8242;? n</span></p>
<p><span style="color: #808080;">mv: overwrite `./ib_logfile0&#8242;? n</span></p>
<p><span style="color: #808080;">mv: overwrite `./ib_logfile1&#8242;? n</span></p>
<p><span style="color: #808080;">mv: overwrite `./mysql-slow.log&#8217;? y</span></p>
<p><span style="color: #00ff00;">root@server:/var/lib/mysql# /etc/init.d/mysql restart</span></p>
<p><span style="color: #00ff00;">Shutting down MySQL. SUCCESS! </span></p>
<p><span style="color: #808080;"><span style="color: #00ff00;">Starting MySQL. SUCCESS!</span><span style="color: #00ff00;"> </span></span></p>
<p>Thus if you have similar problems, the first thing is to check the MySQL error log and don&#8217;t believe the misleading error about the PID <img src='http://linux.bgsnow.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>]]></content:encoded>
			<wfw:commentRss>http://linux.bgsnow.com/starting-mysql-error-manager-of-pid-file-quit-without-updating-file.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
