B
|
bkersey 2/11/2007 |
[codebox] $strSQLInsert = "INSERT INTO elo_value (ID_elo, ID_player, ID_game, ID_country, elo) values (NULL,'$data["ID_player"]','1','".$_SESSION["GID_country"]."','1000')"; db_exec($strSQLInsert,$conn); [/codebox]
|
K
|
kenny_robb author 2/12/2007 |
This may be totally wrong, but do you normally enclose number fields in single quotes?
|
![]() |
Alexey admin 2/12/2007 |
Kenny, $strSQLInsert = "INSERT INTO elo_value (ID_elo, ID_player, ID_game, ID_country, elo) values (NULL,'".$data["ID_player"]."','1','".$_SESSION["GID_country"]."','1000')";db_exec($strSQLInsert,$conn);
|
K
|
kenny_robb author 2/12/2007 |
Kenny, you have an error in PHP syntax. Here is the correct statement. You can learn some PHP at the following sites: http://www.php.net/manual/en/langref.php http://www.webcheatsheet.com/php http://www.w3schools.com/php/
|
J
|
Jane 2/12/2007 |
Hi, $strSQLInsert = "INSERT INTO elo_value (ID_elo, ID_player, ID_game, ID_country, elo) values (NULL,".$data["ID_player"].",'1','".$_SESSION["GID_country"]."','1000')";db_exec($strSQLInsert,$conn);
|
K
|
kenny_robb author 2/12/2007 |
Hi, if the type of your ID_player field is NUMBER you don't need to use single quotes around field value: Also I recommend you to check another fields in your query.
|
J
|
Jane 2/12/2007 |
Here is the correct SQL query: $strSQLInsert = "INSERT INTO elo_value (ID_elo, ID_player, ID_game, ID_country, elo) values (NULL,".$data["ID_player"].",1,".$_SESSION["GID_country"].",1000)"; |
K
|
kenny_robb author 2/12/2007 |
Thanks Guys I rally do appreciate your help but it's still not doing it. The error keeps coming up. |
J
|
Jane 2/12/2007 |
I recommend you to print your SQL query on the page before executing: $strSQLInsert = "INSERT INTO elo_value (ID_elo, ID_player, ID_game, ID_country, elo) values (NULL,".$data["ID_player"].",1,".$_SESSION["GID_country"].",1000)"; echo $strSQLInsert;
|
K
|
kenny_robb author 2/12/2007 |
Jane, |
J
|
Jane 2/12/2007 |
Use the following event code: function AfterAdd() { //** Insert a record into another table **** global $conn; $strSQLQuery = "select ID_player from elo_player where name='".$_SESSION["Gname"]."'; $rsResult = db_query($strSQLQuery,$conn); $data=db_fetch_array($rsResult); $strSQLInsert = "INSERT INTO elo_value (ID_elo, ID_player, ID_game, ID_country, elo) values (NULL,".$data["ID_player"].",1,".$_SESSION["GID_country"].",1000)"; echo $strSQLInsert; }
|
K
|
kenny_robb author 2/12/2007 |
OK finally solved the problem....it was a missing " at the end of the initial query... |