Jump to content

[SOLVED] Using Isset


Daney11

Recommended Posts

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.