Jump to content

update error


dflow

Recommended Posts

im joinng 2 tables

for example if i enter a statusID as 89

then it will update both tables in the db  but when i echo it in or refresh the page i get once the 89 and a new refresh updates it with

a "0" instead of 89  :confused:

here is the testing code:

and how will you redirect it when the action is succesful?

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

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}

$colname_RsProposal = "-1";
if (isset($_GET['PropID'])) {
  $colname_RsProposal = $_GET['PropID'];
}
mysql_select_db($database_international, $international);
$query_RsProposal = sprintf("SELECT * FROM proposals WHERE ProposalID = %s", GetSQLValueString($colname_RsProposal, "int"));
$RsProposal = mysql_query($query_RsProposal, $international) or die(mysql_error());
$row_RsProposal = mysql_fetch_assoc($RsProposal);
$totalRows_RsProposal = mysql_num_rows($RsProposal);
?>

<form name="form2" method="post" action="<?php echo $update_tables_action; ?>">
  <label>StatusID
  <input name="StatusID" type="text" id="StatusID" value="<?php echo $row_RsProposal['StatusID']; ?>">
  </label>
  <?php echo $row_RsProposal['StatusID']; ?>
  <p>
    <label>RequestID
    <input name="RequestID" type="text" id="RequestID" value="<?php echo $row_RsProposal['RequestID']; ?>">
    </label>
  </p>
  <p>
    <label>
    <input type="submit" name="button" id="button" value="Submit">
    </label>
  </p>
</form>
<?php
$StatusID = $_POST['StatusID'];
$ProposalID = $_GET['PropID'];
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("international", $con);

$update_tables_action = mysql_query("UPDATE proposals, contact_form
     SET contact_form.StatusID = '$StatusID', proposals.StatusID= '$StatusID'
        WHERE proposals.RequestID = contact_form.RequestID
        AND proposals.ProposalID = '$ProposalID'") or trigger_error(mysql_error(),E_USER_ERROR);



mysql_close($con);

mysql_free_result($RsProposal);
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.