<?php
$username = $_POST['username'];
$score = $_POST['score'];
$mysqlhost = "localhost"; // MySQL-Host angeben
$mysqluser = "***********"; // MySQL-User angeben
$mysqlpwd = "***********"; // Passwort angeben
$connection = mysql_connect($mysqlhost, $mysqluser, $mysqlpwd) or die("Verbindungsversuch fehlgeschlagen");
$mysqldb="db2507004-seminarfach"; // Gewuenschte Datenbank angeben
mysql_select_db($mysqldb, $connection) or die("Konnte die Datenbank nicht waehlen.");
$sql = "INSERT INTO highscore (username, score) VALUES ('".$username."' , '".$score."');";
$query = "$connection, $sql";
$db_erg = mysql_query($query) or die("Anfrage fehlgeschlagen: " . mysql_error());
?>
always when i try to insert data into my table i get this error:"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 'Resource id #2, INSERT INTO highscore (username, score) VALUES ('peter silie' , ' at line 1" and i don't know what is wrong with it.
in my table username is a varchar and score an int.
hope someone could help me.