dflow Posted August 30, 2009 Share Posted August 30, 2009 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 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 https://forums.phpfreaks.com/topic/172465-update-error/ Share on other sites More sharing options...
fenway Posted September 7, 2009 Share Posted September 7, 2009 Echo the update statement alone. Link to comment https://forums.phpfreaks.com/topic/172465-update-error/#findComment-914137 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.