 <p>Here is a working version</p> <p>Changes:</p> <ul> <li>Added <code>$dbname</code> to <code>mysqli_connect</code> function</li> <li>Added the backtick ` char between the table names, to avoid errors with reserved keyword from MySQL</li> <li>Changed mysql_ functions to mysqli_</li> <li>Close the file</li> <li>Close the connection</li> </ul> <p><a href="http://pastebin.com/B3jZ4wc9" rel="nofollow">Here</a> is the code</p> <p><strong>NOTE:</strong> sorry I don't why, but when I pasted the code in the answer, all de code identation was messed up, even trying to indent it properly, I wasted like 10 minutes :(</p>