-7

connection.php:

$con = mysql_connect("localhost","networka_root","secret");
if (!$con) die('Could not connect: ' . mysql_error()); 

mysql_select_db("networka_simple_login", $con);

$sql="INSERT INTO `networka` (`username`, `password`,)
             VALUES ('$_POST[username]','$_POST[password]')";

if (!mysql_query($sql, $con)) die('Error: ' . mysql_error()); 
echo "1 record added";

mysql_close($con)

The error I get when I put in my username and password:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ) VALUES ('username','password') at line 1

tbodt
  • 16,609
  • 6
  • 58
  • 83
Jordan
  • 77
  • 1
  • 3
  • If you didn't already saw it you can take a tour here: http://stackoverflow.com/tour and see how the site works! (Welcome on SO!) – Rizier123 Jan 30 '15 at 02:04

1 Answers1

7

You have an unnecessary comma after your column identifier list:

(username, password,) 
                 ^^^^
                 HERE

Remove it.

Please, don't use mysql_* functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial. You are also wide open to SQL injections

Community
  • 1
  • 1
John Conde
  • 217,595
  • 99
  • 455
  • 496