i have problem with my syntax.. please help me..

<?php require_once('../Connections/epurse.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE user WHERE money=%s",
                       GetSQLValueString($_POST['money'], "int"));

  mysql_select_db($database_epurse, $epurse);
  $Result1 = mysql_query($updateSQL, $epurse) or die(mysql_error());
}

$colname_update = "1";
if (isset($_POST['result'])) {
  $colname_update = (get_magic_quotes_gpc()) ? $_POST['result'] : addslashes($_POST['result']);
}
mysql_select_db($database_epurse, $epurse);
$query_update = sprintf("SELECT money FROM `user` WHERE 'money' = %s", $colname_update);
$update = mysql_query($query_update, $epurse) or die(mysql_error());
$row_update = mysql_fetch_assoc($update);
$totalRows_update = mysql_num_rows($update);

if (($_POST[val1] == "") || ($_POST[val2] == "") || ($_POST[calc] =="")) {
  header("Location: calculate_form.html");
  exit;
}
if ($_POST[calc] == "add") {
  $result = $_POST[val1] + $_POST[val2];
} else if ($_POST[calc] == "subtract") {
  $result = $_POST[val1] - $_POST[val2];
} else if ($_POST[calc] == "multiply") {
  $result = $_POST[val1] * $_POST[val2];
} else if ($_POST[calc] == "divide") {
  $result = $_POST[val1] / $_POST[val2];
}
echo "<title>Calculation Result</title>";
echo "<p>The result of the calculation is: $result</p>";
echo "<p><a href=\"calculate_form.html\" target=\"_parent\">Do Another</a></p>";

mysql_free_result($update);
?>

<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
  <table align="center">
    <tr valign="baseline">
      <td nowrap align="right">Money:</td>
      <td><?php echo $result;?></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">&nbsp;</td>
      <td><input type="submit" value="Update record"></td>
    </tr>
  </table>
  <input type="hidden" name="MM_update" value="form1">
  <input type="hidden" name="money" value="<?php echo $result; ?>">
</form>
<p>&nbsp;</p>

Recommended Answers

All 2 Replies

*cough* You definitely just bumped a 3+ year old thread along with ignoring code tags. Aside from that A) What is the error, saying "I have an error" is the equivalent of a Check Engine light.

@ShawnCplus - post moved

@squidthekiller - Do not piggyback threads (aka "hijack" threads) by posting your question as a reply to another question.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.