close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

posting file name to db not using data assist

Thread began 10/12/2009 2:00 pm by randall390915 | Last modified 10/13/2009 5:28 pm by randall390915 | 3450 views | 3 replies

randall390915

I don't get it.

I placed the server file name code into a hidden input named "petImage". but it returns a "null" error.

here is my code:

<?php require_once('Connections/petriever.php'); ?>
<?php require_once("WA_DigitalFilePro/HelperPHP.php"); ?>
<?php
session_start();
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;
}
}

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

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO pets (petID, ownerID, petName, petType, petImage, gender, breed, color1, color2) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['petID'], "text"),
GetSQLValueString($_POST['ownerID'], "int"),
GetSQLValueString($_POST['petName'], "text"),
GetSQLValueString($_POST['petType'], "text"),
GetSQLValueString($_POST['petImage'], "text"),
GetSQLValueString($_POST['gender'], "text"),
GetSQLValueString($_POST['breed'], "text"),
GetSQLValueString($_POST['color1'], "text"),
GetSQLValueString($_POST['color2'], "text"));

mysql_select_db($database_petriever, $petriever);
$Result1 = mysql_query($insertSQL, $petriever) or die(mysql_error());

$insertGoTo = "owner.php" ;
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

$vrOwnerID_rsOwner = "-1";
if (isset($_SESSION['MM_Username'])) {
$vrOwnerID_rsOwner = $_SESSION['MM_Username'];
}
$vrOwnerID_rsOwner = "-1";
if (isset($_SESSION['MM_Username'])) {
$vrOwnerID_rsOwner = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
}
mysql_select_db($database_petriever, $petriever);
$query_rsOwner = sprintf("SELECT owners.ownerID, owners.firstName FROM owners WHERE owners.email=%s", GetSQLValueString($vrOwnerID_rsOwner, "text"));
$rsOwner = mysql_query($query_rsOwner, $petriever) or die(mysql_error());
$row_rsOwner = mysql_fetch_assoc($rsOwner);
$totalRows_rsOwner = mysql_num_rows($rsOwner);?>
<?php
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "images/petsLarge/",
'FileName' => "".((isset($_POST["petID"]))?$_POST["petID"]:"") ."",
'DefaultFileName' => "",
'ResizeType' => "1",
'ResizeWidth' => "120",
'ResizeHeight' => "120",
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult1_1 End
// WA_UploadResult1 Params End
?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if(($_SERVER["REQUEST_METHOD"] == "POST") && (isset($_SERVER["HTTP_REFERER"]) && strpos(urldecode($_SERVER["HTTP_REFERER"]), urldecode($_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"])) > 0) && isset($_POST)){
WA_DFP_UploadFiles("WA_UploadResult1", "upload", "0", "", "PNG:9", $WA_UploadResult1_Params);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<link href="CSS/petriever.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
</head>

<body>
<form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Pet ID:</td>
<td><span id="sprytextfield1">
<input type="text" name="petID" value="" size="32" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Pet Name:</td>
<td><input type="text" name="petName" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Pet Type:</td>
<td><select name="petType">
<option value="Cat" <?php if (!(strcmp("Cat", ""))) {echo "SELECTED";} ?>>Cat</option>
<option value="Dog" <?php if (!(strcmp("Dog", ""))) {echo "SELECTED";} ?>>Dog</option>
<option value="Other" <?php if (!(strcmp("Other", ""))) {echo "SELECTED";} ?>>Other</option>
</select>
<select name="select" id="select">
</select> </td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Gender:</td>
<td valign="baseline"><table>
<tr>
<td><input type="radio" name="gender" value="Male" />
Male</td>
</tr>
<tr>
<td><input type="radio" name="gender" value="Female" />
Female</td>
</tr>
</table></td>
</tr>
<tr><td nowrap="nowrap" align="right">Pet Photo:</td><td><input type="file" name="upload" id="upload" /></td></tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Breed:</td>
<td><input type="text" name="breed" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Main Color:</td>
<td><input type="text" name="color1" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Accent Color:</td>
<td><input type="text" name="color2" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td><input type="submit" value="Insert record" /></td>
</tr>
</table>
<input type="hidden" name="ownerID" value="<?php echo $row_rsOwner['ownerID']; ?>" />
<input type="hidden" name="petImage" value="<?php echo $WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]; ?>" />
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "custom", {pattern:"AAA-00000000", validateOn:["blur"]});
//-->
</script>
</body>
</html>
<?php
mysql_free_result($rsOwner);
?>

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...