Daney11 Posted March 20, 2007 Share Posted March 20, 2007 Hi guys, I get this error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 When using <?php if (isset($_POST['givemoney'])) { $_GET['money']; $strQuery = "UPDATE `teams` SET money = '$money' WHERE player_id = $id"; mysql_query($strQuery,$db) or die(mysql_error()); } ?> and line 1 is <?php :S *** I get the error when i submit the form. Any ideas guys. Thanks Link to comment https://forums.phpfreaks.com/topic/43469-solved-using-isset/ Share on other sites More sharing options...
Orio Posted March 20, 2007 Share Posted March 20, 2007 Try: <?php if (isset($_POST['givemoney'])) { $money = $_GET['money']; $strQuery = "UPDATE `teams` SET money = '$money' WHERE player_id = '$id'"; mysql_query($strQuery,$db) or die(mysql_error()); } ?> Orio. Link to comment https://forums.phpfreaks.com/topic/43469-solved-using-isset/#findComment-211091 Share on other sites More sharing options...
Daney11 Posted March 20, 2007 Author Share Posted March 20, 2007 Its not giving me the error anymore but its also not getting the values out of my form for some reason and all the names are correct :S Link to comment https://forums.phpfreaks.com/topic/43469-solved-using-isset/#findComment-211105 Share on other sites More sharing options...
obsidian Posted March 20, 2007 Share Posted March 20, 2007 Its not giving me the error anymore but its also not getting the values out of my form for some reason and all the names are correct :S You're checking to see if $_POST['givemoney'] is set, and then you're trying to get a value from $_GET['money']. If "money" is the name of one of your form fields and your form is being posted, you'll need to access the money field through $_POST as well, instead of $_GET. Link to comment https://forums.phpfreaks.com/topic/43469-solved-using-isset/#findComment-211107 Share on other sites More sharing options...
Daney11 Posted March 20, 2007 Author Share Posted March 20, 2007 My form is. <?php $name = "Dane"; $money = "1000000"; ?> <form action="player_money_create.php" method="post"> <table width="654" cellpadding="0" cellspacing="0" align="center" class="leagueoutline"> <tr> <td width="168" height="20" align="left" valign="middle"><?php echo " $name"; ?></td> <td width="168" height="20" align="left" valign="middle"><input class="shoutbox" name="money" type="text" value="<?php echo "$money" ?>" /></td> </tr> </table> <input name="givemoney" type="submit" class="shoutbox" onClick="return confirmMoney()" value="Click Here To Submit"> </form> Thanks Link to comment https://forums.phpfreaks.com/topic/43469-solved-using-isset/#findComment-211113 Share on other sites More sharing options...
obsidian Posted March 20, 2007 Share Posted March 20, 2007 Like I said above, your form is using the POST method, so you need to access your 'money' variable through $_POST, not $_GET: <?php if (isset($_POST['givemoney'])) { $money = $_POST['money']; // This is the line with the change to $_POST $strQuery = "UPDATE `teams` SET money = '$money' WHERE player_id = '$id'"; mysql_query($strQuery,$db) or die(mysql_error()); } ?> Link to comment https://forums.phpfreaks.com/topic/43469-solved-using-isset/#findComment-211116 Share on other sites More sharing options...
Daney11 Posted March 20, 2007 Author Share Posted March 20, 2007 Thanks a lot. That works fine. Thanks again Dane Link to comment https://forums.phpfreaks.com/topic/43469-solved-using-isset/#findComment-211119 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.