I'm trying to insert variables from $_GET into a MySQL Database. I am a noob and I can't figure out what is wrong with it! The code runs and it outputs the user and userid added to table but when I check in phpMyAdmin
$username = "username";
$password = "password";
$host = "host";
$database = "database";
$input_username = $_GET["username"];
$input_userId = $_GET["userId"];
mysql_connect($host,$username,$password);
mysql_select_db($database) or die("Couldn't select database: " . $database);
$sql = "INSERT INTO users( UserId , Username ) VALUES('$_GET['userId']','$_GET['username']');";
echo "Username: " . $input_username . ", UserId: " . $input_userId ." added to table.";
mysql_close();
EDIT: I altered the code to fit the replied answers but now I get this error:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in PAGEPATH on line 10