<table align="center">
<a href="http://www.officalhalo.com">Home</a> 

<a href="/tournament/FFA.htm">FFA</a> |

<a href="/tournament/signup.htm">Sign Up</a> |

<a href="/tournament/results.htm">Results</a>
<h3 align="center">Participants</h3>
  if (!$gamertag || !$eaddress)
      echo 'You have not entered all of the required information.<br />'
           .'Please go back and try again.';
  if (!get_magic_quotes_gpc())
      $gamertag = addslashes($gamertag);
      $eaddress = addslashes($eaddress);
  @ $db = new mysqli('localhost', 'username', 'password', 'chilllax_participants');
if (mysqli_connect_error())
    echo 'Error: Could not connect to database. Please try again later.';

$query = "insert into participants values
          ('$gamertag', '$eaddress'}";
$result = $db->query($query);
if ($result)
    echo $db->affected_rows.' participant added.

Theres the code in my page. 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. This

$query = "insert into participants values
          ('$gamertag', '$eaddress'}";

Thanks for any help. I hope that made sense. :confused:

12 Years
Discussion Span
Last Post by DGStudios

Look at the spot where you are declaring the value of $eaddress

you have written $POST
it needs to be $_POST

keep in mind while debugging the line number is usually close depending on the error. Bad varriables like that are usually DEAD on. Also the simplest mistakes the ones you never think you'd make are often the cause. First rule of programming, if you can't mess it up, that probably what you messed up.


thanks but it still says error unexpected variable on line 53 which is </html> its not even a variable or related to php? I dont think this code is correct

$query = "insert into participants values
('$gamertag', '$eaddress'}";

How does that bit of code know which table to put the variable info into, the table and variable names are the same but can if recognize that?


First. You open a ( and close with a Curly bracket }

Also are those the ONLY TWO colomns in the table. It defaults to the order in which they are listed as the order they show up in the table.

if the table has three colomns and you're only inputing 2 then you need to change the query to tell it thats the only thing your inputting as so.

Insert into tablename (colomn1, colomn3) Values (value1, value2);

Naturally that means you can pick the individual colomns to place data in.

However, it is most likely the curly bracket closing Parenthesis that is causing the problem there if the tables are the same.

also I'm not sure about PHP 5 but I know in four the !$var1 would turn true only if the value = NULL. A 0 length string is not a NULL string.

I'm not sure so it might still work but you might want to consider for easier reading and debugging or just making sure it works. using: strlen($var1) <1
That will return true if the value isn't there. This is the code I've used a few times.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.