I'm still learning PHP/mySQL and for the life of me I can't figure out what's wrong with my code. I'm trying to take several javascript variables from an html page and add them to a table in my database. I'm using ajax and passing the variables in the URL, then retrieving them with $_GET. I've tested this and the variables are passed correctly to the PHP script, but they don't appear in the database. All I know is that the script dies on this line: mysql_query($query) or die('data entry failed'); I used phpmyadmin to create the table and my host is 000webhost. Thanks in advance!
$database='a9293297_blog';
$con=mysql_connect('mysql2.000webhost.com','my_username','my_password');
mysql_select_db($database,$con) or die('failed to connect to database');
$username=$_GET['username'];
$password=$_GET['password'];
$charName=$_GET['charName'];
$sex=$_GET['sex'];
$class=$_GET['class'];
$race=$_GET['race'];
$str=$_GET['str'];
$sta=$_GET['sta'];
$dex=$_GET['dex'];
$int=$_GET['int'];
$cha=$_GET['cha'];
$query="INSERT INTO Players (username, password, charName, sex, class, race, str, sta, dex, int, cha)
VALUES ('".$username."', '".$password."', '".$charName."', '".$sex."', '".$class."', '".$race."', '".$str."', '".$sta."', '".$dex."', '".$int."', '".$cha."')";
mysql_query($query) or die('data entry failed');
mysql_close($con);