I've got stuck again, so would be grateful for some assistance.
I'm updating a short text from a form to two msql tables simultaineously, and then moving on to another page, which is where the problem lies. I want to pass on a Primary Key to filter the recordset in the nest page, but whatever I try fails. I tend to get the error message:
"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"
and I notice in the address bar I get more than the single variable that I want being transmitted.
I am using DWmx to write the code. As there are two pages invovled I'm unsure which to include, but this is from Page One
Sorry there's so much, but I don't know where the problem lies.
I'm updating a short text from a form to two msql tables simultaineously, and then moving on to another page, which is where the problem lies. I want to pass on a Primary Key to filter the recordset in the nest page, but whatever I try fails. I tend to get the error message:
"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"
and I notice in the address bar I get more than the single variable that I want being transmitted.
I am using DWmx to write the code. As there are two pages invovled I'm unsure which to include, but this is from Page One
Code:
<?php require_once('../../Connections/tormented3.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 cel_contents SET cel_org=%s WHERE cel_pk=%s",
GetSQLValueString($_POST['textfield'], "text"),
GetSQLValueString($_POST['contentField'], "int"));
mysql_select_db($database_tormented3, $tormented3);
$Result1 = mysql_query($updateSQL, $tormented3) or die(mysql_error());
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE chk_sixmonth SET ck_organisation=%s WHERE ck_pk=%s",
GetSQLValueString($_POST['textfield'], "text"),
GetSQLValueString($_POST['contactField'], "int"));
mysql_select_db($database_tormented3, $tormented3);
$Result1 = mysql_query($updateSQL, $tormented3) or die(mysql_error());
$updateGoTo = "../contact_update/chk_organ.php?org=" . $row_rstSix['ck_pk'] . "";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_rstSix = "1";
if (isset($_GET['organ'])) {
$colname_rstSix = (get_magic_quotes_gpc()) ? $_GET['organ'] : addslashes($_GET['organ']);
}
mysql_select_db($database_tormented3, $tormented3);
$query_rstSix = sprintf("SELECT ck_pk, ck_organisation FROM chk_sixmonth WHERE ck_organisation = '%s'", $colname_rstSix);
$rstSix = mysql_query($query_rstSix, $tormented3) or die(mysql_error());
$row_rstSix = mysql_fetch_assoc($rstSix);
$totalRows_rstSix = mysql_num_rows($rstSix);
mysql_select_db($database_tormented3, $tormented3);
$query_rstCont = "SELECT cel_pk, cel_org FROM cel_contents";
$rstCont = mysql_query($query_rstCont, $tormented3) or die(mysql_error());
$row_rstCont = mysql_fetch_assoc($rstCont);
$totalRows_rstCont = mysql_num_rows($rstCont);
?>
<!DOCTYPE HTML PUBLIC "-//W3C/etc...
Sorry there's so much, but I don't know where the problem lies.