chilllax
04-14-2006, 01:42 AM
<?php
$gamertag=$_POST['gamertag'];
$eaddress=$_POST['eaddress'];
if (!$gamertag || !$eaddress)
{
echo 'You have not entered all of the required information.<br />'
.'Please go back and try again.';
exit;
}
if (!get_magic_quotes_gpc())
{
$gamertag = addslashes($gamertag);
$eaddress = addslashes($eaddress);
}
@ $db = new mysqli('localhost', 'chilllax_chill', 'red123', 'chilllax_participants');
if (mysqli_connect_error())
{
echo 'Error: Could not connect to database. Please try again later.';
exit;
}
$query = "insert into participants values
('$gamertag', '$eaddress'}";
$result = $db->query($query);
if ($result)
echo $db->affected_rows.' participant added.
$db->close();
?>
Theres the code in my script. I have the database set up and also the correct number of tables. My problem is whenever I try and run this script this error comes up parse error, unexpected $. Why is this. Also I am going by a php book thats infront of me and I dont really understand the bit of code that actually inserts the data into the database. How does it know which table to place the variables into? I hope this made sense. Thanks for any help.
$gamertag=$_POST['gamertag'];
$eaddress=$_POST['eaddress'];
if (!$gamertag || !$eaddress)
{
echo 'You have not entered all of the required information.<br />'
.'Please go back and try again.';
exit;
}
if (!get_magic_quotes_gpc())
{
$gamertag = addslashes($gamertag);
$eaddress = addslashes($eaddress);
}
@ $db = new mysqli('localhost', 'chilllax_chill', 'red123', 'chilllax_participants');
if (mysqli_connect_error())
{
echo 'Error: Could not connect to database. Please try again later.';
exit;
}
$query = "insert into participants values
('$gamertag', '$eaddress'}";
$result = $db->query($query);
if ($result)
echo $db->affected_rows.' participant added.
$db->close();
?>
Theres the code in my script. I have the database set up and also the correct number of tables. My problem is whenever I try and run this script this error comes up parse error, unexpected $. Why is this. Also I am going by a php book thats infront of me and I dont really understand the bit of code that actually inserts the data into the database. How does it know which table to place the variables into? I hope this made sense. Thanks for any help.