(EDIT: I added
tags around your code sample. Please be sure to use them in all future posts. -- NogDog)[/i]
Can anyone please help me out with this... trying to figure out why I keep getting the "Query was empty" error. I am going bonkers...
Thanks in advance!
-Dan
[code=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 amenities SET amenitiesId=%s, categoryId=%s, amenities=%s WHERE amenitiesId=%s",
GetSQLValueString($_POST['amenitiesId'], "int"),
GetSQLValueString($_POST['categoryId'], "int"),
GetSQLValueString($_POST['amenities'], "text"));
mysql_select_db($database_CN_vacationpropertytrader_com, $CN_vacationpropertytrader_com);
$Result1 = mysql_query($updateSQL, $CN_vacationpropertytrader_com) or die(mysql_error());
$updateGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_rsAmenities = "1";
if (isset($_GET['amenitiesId'])) {
$colname_rsAmenities = (get_magic_quotes_gpc()) ? $_GET['amenitiesId'] : addslashes($_GET['amenitiesId']);
}
mysql_select_db($database_CN_vacationpropertytrader_com, $CN_vacationpropertytrader_com);
$query_rsAmenities = sprintf("SELECT * FROM amenities WHERE amenitiesId = %s", $colname_rsAmenities);
$rsAmenities = mysql_query($query_rsAmenities, $CN_vacationpropertytrader_com) or die(mysql_error());
$row_rsAmenities = mysql_fetch_assoc($rsAmenities);
$totalRows_rsAmenities = mysql_num_rows($rsAmenities);
?>
<html><!-- InstanceBegin template="/Templates/vaca_admin.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="doctitle" -->
<title>Unit Type Edit - World Vacation Properties Admin</title>
<!-- InstanceEndEditable --><link href="pro-admin_css.css" rel="stylesheet" type="text/css">
<!-- InstanceBeginEditable name="head" -->
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
<!-- InstanceEndEditable -->
</head>
<body>
<p align="center"><a name="top"></a><a href="index.php">Site Admin Home</a> </p>
<table width="700" border="1" align="center" cellpadding="3" cellspacing="0" bordercolor="#333333" class="regtxt">
<tr>
<td width="50%" colspan="2"><p align="center"><strong>Please use this page to <!-- InstanceBeginEditable name="purpose" -->edit an amenity. <!-- InstanceEndEditable --></strong></p>
<!-- InstanceBeginEditable name="body" -->
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center" class="regtxt">
<tr valign="baseline">
<td nowrap align="right"><strong>Amenity ID:</strong></td>
<td><?php echo $row_rsAmenities['amenitiesId']; ?></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><strong>Category ID:</strong></td>
<td><?php echo $row_rsAmenities['categoryId']; ?></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><strong>Amenity Content:</strong></td>
<td><input name="amenities" type="text" value="<?php echo $row_rsAmenities['amenities']; ?>" size="30" maxlength="60"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" onClick="MM_validateForm('amenities','','R');return document.MM_returnValue" value="Update record"></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="amenitiesId" value="<?php echo $row_rsAmenities['amenitiesId']; ?>">
</form>
<p> </p>
<!-- InstanceEndEditable -->
<p align="right"><a href="#top">-TOP-</a></p></td>
</tr>
</table>
<p align="center" class="regtxt">Designed and Hosted by <a href="http://www.uniquewebsites.com/" target="_blank">Unique Web Sites, Inc.</a> </p>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($rsAmenities);
?>