Copy link to clipboard
Copied
I have a problem with an update page on my website
Here's how it work
Please can someone have a look at this, code,
Also, is there a way of 'stepping through' dreamweaver code to debug it?
Thanks
Adam
$colname_Advert = "-1";
if (isset($_GET['advert_id'])) {
$colname_Advert = $_GET['advert_id'];
}
mysql_select_db($database_guitarswap_db, $guitarswap_db);
$query_Advert = sprintf("SELECT * FROM advert WHERE advert_id = %s", GetSQLValueString($colname_Advert, "int"));
$Advert = mysql_query($query_Advert, $guitarswap_db) or die(mysql_error());
$row_Advert = mysql_fetch_assoc($Advert);
$totalRows_Advert = mysql_num_rows($Advert);
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form4"))
{
//Сheck that we have a file
if((!empty($_FILES["PictureLocation"])) && ($_FILES['PictureLocation']['error'] == 0))
{
//Check if the file is JPEG image and it's size is less than 350Kb
$filename = basename($_FILES["PictureLocation"]["name"]);
$ext = substr($filename, strrpos($filename, '.') + 1);
if (($ext == "jpg") && ($_FILES["PictureLocation"]["type"] == "image/jpeg") &&
($_FILES["PictureLocation"]["size"] < 350000))
{
//Determine the path to which we want to save this file
$newname = dirname(__FILE__).'/upload/'.$filename;
//Check if the file with the same name is already exists on the server
if (!file_exists($newname))
{
//Attempt to move the uploaded file to it's new place
if ((move_uploaded_file($_FILES['PictureLocation']['tmp_name'],$newname)))
{
// echo "It's done! The file has been saved as: ".$newname;
}
else
{
// echo "Error: A problem occurred during file upload!";
}
}
else
{
// echo "Error: File ".$_FILES["PictureLocation"]["name"]." already exists";
}
}
else
{
// echo "Error: Only .jpg images under 350Kb are accepted for upload";
}
}
else
{
// echo "Error: No file uploaded";
$filename=$row_Advert['PictureLocation'];
}
// set default opentoalloffers
if (!isset($_POST['checkopentoalloffers']))
{
$_POST['checkopentoalloffers'] = 'n';
}
$updateSQL = sprintf("UPDATE advert SET PictureLocation=%s, O_Make=%s, O_Model=%s, O_Country=%s, O_Year=%s, O_Colour=%s, O_Body=%s, O_Neck=%s, O_Fingerboard=%s, O_Pickups=%s, `value`=%s, `condition`=%s, W_Make=%s, W_Model=%s, W_Country=%s, W_Year=%s, W_Colour=%s, W_Body=%s, W_Neck=%s, W_Fingerboard=%s, W_Pickups=%s, Comments=%s, opentoalloffers=%s, ChangeFlg = %s WHERE advert_id=%s",
GetSQLValueString($filename, "text"),
GetSQLValueString($_POST['O_Make'], "text"),
GetSQLValueString($_POST['O_Model'], "text"),
GetSQLValueString($_POST['O_Country'], "text"),
GetSQLValueString($_POST['O_Year'], "date"),
GetSQLValueString($_POST['O_Colour'], "text"),
GetSQLValueString($_POST['O_Body'], "text"),
GetSQLValueString($_POST['O_Neck'], "text"),
GetSQLValueString($_POST['O_Fingerboard'], "text"),
GetSQLValueString($_POST['O_Pickups'], "text"),
GetSQLValueString($_POST['value'], "int"),
GetSQLValueString($_POST['condition'], "text"),
GetSQLValueString($_POST['W_Make'], "text"),
GetSQLValueString($_POST['W_Model'], "text"),
GetSQLValueString($_POST['W_Country'], "text"),
GetSQLValueString($_POST['W_Year'], "date"),
GetSQLValueString($_POST['W_Colour'], "text"),
GetSQLValueString($_POST['W_Body'], "text"),
GetSQLValueString($_POST['W_Neck'], "text"),
GetSQLValueString($_POST['W_Fingerboard'], "text"),
GetSQLValueString($_POST['W_Pickups'], "text"),
GetSQLValueString($_POST['Comments'], "text"),
GetSQLValueString($_POST['checkopentoalloffers'], "text"),
GetSQLValueString('y', "text"),
GetSQLValueString($_POST['advert_id'], "int"));
mysql_select_db($database_guitarswap_db, $guitarswap_db);
$Result1 = mysql_query($updateSQL, $guitarswap_db) or die(mysql_error());
$updateGoTo = "Member2.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
?>
<!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="Layout3.css" rel="stylesheet" type="text/css" /><!--[if IE 5]>
<style type="text/css">
/* place css box model fixes for IE 5* in this conditional comment */
.twoColFixLtHdr #sidebar1 { width: 230px; }
</style>
<![endif]--><!--[if IE]>
<style type="text/css">
/* place css fixes for all versions of IE in this conditional comment */
.twoColFixLtHdr #sidebar1 { padding-top: 30px; }
.twoColFixLtHdr #mainContent { zoom: 1; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]-->
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
background-color: #FFF;
margin-left: 20px;
}
.twoColFixLtHdr #container #main3 #form1 div fieldset {
border: thin ridge #CCC;
}
-->
</style>
<script type="text/javascript">
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args+".location='"+args[i+1]+"'");
}
//-->
</script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
</head>
<body class="twoColFixLtHdr">
<div id="container">
<div id="header">
<div id="Righty">
<ul id="MenuBar2" class="MenuBarHorizontal">
<li><a href="index.php">Search</a> </li>
<li><a href="Member2.php">Members</a></li>
</ul>
<p> </p>
</div>
<span id="LoginDiv">
<?php
if (isset($_SESSION['MM_Username']))
{
echo "hello ". $_SESSION['MM_Username']. "";
echo " <a href='Logout.php'>Log out</a> ";
}
else
{
echo "
<a href='Login.php'>Login</a> / <a href='Register.php'>Register</a>
";
}
?>
</a></span>
<div id="Middle">
<h1 align="center">GuitarSwap</h1>
</div>
</div>
<div id="sidebar1">
<h4>Members Area</h4>
<ul id="MenuBar1" class="MenuBarVertical">
<li><a href="Member2.php">My Adverts</a></li>
<li><a href="NewAdvert.php">Create new Advert</a></li>
<li><a href="UpdateUserDets.php">My Account</a></li>
</ul>
<h3> </h3>
</div>
<div id="mainContent">
<h4>Update Advert</h4>
<!-- end #mainContent -->
</div>
<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats -->
<div id="main3">
<div id="main">
<fieldset>
<legend>Please update advert details and confirm</legend>
<form action="<?php echo $editFormAction; ?>" enctype="multipart/form-data" method="post" name="form4" id="form4">
<input type="hidden" name="advert_id" value="<?php echo $row_Advert['advert_id']; ?>" />
<p></p>
<table width="650" align="center">
<tr valign="baseline">
<td width="17" rowspan="15" valign="middle" nowrap="nowrap"><?php echo "<img src='upload/" .$row_Advert['PictureLocation']."' width='64' height='180'/>" ?></td>
<td width="133" align="right" nowrap="nowrap"> </td>
<td width="240" align="center" bgcolor="#CCCCCC"><strong>Offered</strong></td>
<td width="240" align="center" bgcolor="#CCCCCC"><strong>Wanted</strong></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><strong>Make:</strong></td>
<td bgcolor="#CCFFCC"><input name="O_Make" type="text" value="<?php echo $row_Advert['O_Make']; ?>" size="30" maxlength="15" /></td>
<td bgcolor="#CCFFFF"><input name="W_Make" type="text" value="<?php echo $row_Advert['W_Make']; ?>" size="30" maxlength="15" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><strong>Model:</strong></td>
<td bgcolor="#CCFFCC"><input name="O_Model" type="text" value="<?php echo $row_Advert['O_Model']; ?>" size="30" maxlength="30" /></td>
<td bgcolor="#CCFFFF"><input name="W_Model" type="text" value="<?php echo $row_Advert['W_Model']; ?>" size="30" maxlength="30" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><strong>Country:</strong></td>
<td bgcolor="#CCFFCC"><input name="O_Country" type="text" value="<?php echo $row_Advert['O_Country']; ?>" size="30" maxlength="15" /></td>
<td bgcolor="#CCFFFF"><input name="W_Country" type="text" value="<?php echo $row_Advert['W_Country']; ?>" size="30" maxlength="15" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><strong>Year:</strong></td>
<td bgcolor="#CCFFCC"><span id="sprytextfield1">
<input name="O_Year" type="text" value="<?php echo $row_Advert['O_Year']; ?>" size="4" maxlength="4" />
<span class="textfieldInvalidFormatMsg">Invalid format.</span><span class="textfieldMinValueMsg">The entered value is less than the minimum required.</span><span class="textfieldMaxValueMsg">The entered value is greater than the maximum allowed.</span></span></td>
<td bgcolor="#CCFFFF"><span id="sprytextfield2">
<input name="W_Year" type="text" value="<?php echo $row_Advert['W_Year']; ?>" size="4" maxlength="4" />
<span class="textfieldInvalidFormatMsg">Invalid format.</span><span class="textfieldMinValueMsg">The entered value is less than the minimum required.</span><span class="textfieldMaxValueMsg">The entered value is greater than the maximum allowed.</span></span></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><strong>Colour:</strong></td>
<td bgcolor="#CCFFCC"><input name="O_Colour" type="text" value="<?php echo $row_Advert['O_Colour']; ?>" size="30" maxlength="15" /></td>
<td bgcolor="#CCFFFF"><input name="W_Colour" type="text" value="<?php echo $row_Advert['W_Colour']; ?>" size="30" maxlength="15" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><strong>Body:</strong></td>
<td bgcolor="#CCFFCC"><input name="O_Body" type="text" value="<?php echo $row_Advert['O_Body']; ?>" size="30" maxlength="15" /></td>
<td bgcolor="#CCFFFF"><input name="W_Body" type="text" value="<?php echo $row_Advert['W_Body']; ?>" size="30" maxlength="15" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><strong>Neck:</strong></td>
<td bgcolor="#CCFFCC"><input name="O_Neck" type="text" value="<?php echo $row_Advert['O_Neck']; ?>" size="30" maxlength="15" /></td>
<td bgcolor="#CCFFFF"><input name="W_Neck" type="text" value="<?php echo $row_Advert['W_Neck']; ?>" size="30" maxlength="15" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><strong>Fingerboard:</strong></td>
<td bgcolor="#CCFFCC"><input name="O_Fingerboard" type="text" value="<?php echo $row_Advert['O_Fingerboard']; ?>" size="30" maxlength="15" /></td>
<td bgcolor="#CCFFFF"><input name="W_Fingerboard" type="text" value="<?php echo $row_Advert['W_Fingerboard']; ?>" size="30" maxlength="15" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><strong>Pickups:</strong></td>
<td bgcolor="#CCFFCC"><input name="O_Pickups" type="text" value="<?php echo $row_Advert['O_Pickups']; ?>" size="30" maxlength="15" /></td>
<td bgcolor="#CCFFFF"><input name="W_Pickups" type="text" value="<?php echo $row_Advert['W_Pickups']; ?>" size="30" maxlength="15" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><strong>Condition:</strong></td>
<td bgcolor="#CCFFCC"><label for="condition">
<select name="condition" size="1" id="condition">
<option selected="selected" value="" <?php if (!(strcmp("", $row_Advert['condition']))) {echo "selected=\"selected\"";} ?>>---select---</option>
<option value="immaculate" <?php if (!(strcmp("immaculate", $row_Advert['condition']))) {echo "selected=\"selected\"";} ?>>immaculate</option>
<option value="excellent" <?php if (!(strcmp("excellent", $row_Advert['condition']))) {echo "selected=\"selected\"";} ?>>excellent</option>
<option value="good" <?php if (!(strcmp("good", $row_Advert['condition']))) {echo "selected=\"selected\"";} ?>>good</option>
<option value="well used" <?php if (!(strcmp("well used", $row_Advert['condition']))) {echo "selected=\"selected\"";} ?>>well used</option>
<option value="poor" <?php if (!(strcmp("poor", $row_Advert['condition']))) {echo "selected=\"selected\"";} ?>>poor</option>
</select>
</label></td>
<td bgcolor="#FFFFFF"> </td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><strong>Value:</strong></td>
<td bgcolor="#CCFFCC"><span id="sprytextfield3">
<input name="value" type="text" value="<?php echo $row_Advert['value']; ?>" size="11" maxlength="11" />
<span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
<td bgcolor="#FFFFFF"> </td>
</tr>
<tr valign="baseline">
<td align="right" valign="top" nowrap="nowrap"><strong>Comments:</strong></td>
<td bgcolor="#CCFFCC"><textarea name="Comments" cols="25" rows="3"><?php echo $row_Advert['Comments']; ?></textarea></td>
<td bgcolor="#FFFFFF"> </td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><strong>Picture location</strong></td>
<td bgcolor="#CCFFCC"><label for="checkopentoalloffers"></label> <input type="file" name="PictureLocation" value="<?php echo $row_Advert['PictureLocation']; ?>" size="20" /></td>
<td bgcolor="#FFFFFF"> </td>
</tr>
<tr valign="baseline">
<td height="26" align="right" nowrap="nowrap"><strong>Open to all offers:</strong></td>
<td bgcolor="#CCFFCC"><input name="checkopentoalloffers" type="checkbox" id="checkopentoalloffers" value="y" <?php if (!(strcmp($row_Advert['opentoalloffers'],"y"))) {echo "checked=\"checked\"";} ?> /></td>
<td bgcolor="#FFFFFF"> </td>
</tr>
</table>
<p> </p>
<div id="submitdiv">
<input type="hidden" name="MM_update" value="form4" />
<input name="submit button" type="submit" id="submit button" value="Update Advert" />
</div>
<div id="exitdiv">
<label for="button15"></label>
<input name="button" type="button" id="button15" onclick="MM_goToURL('parent','Member2.php');return document.MM_returnValue" value="Exit" />
<label for="button16"></label>
</div>
<p> </p>
</form>
</fieldset>
<script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "integer", {validateOn:["blur"], minValue:1900, maxValue:2010, isRequired:false});
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "integer", {validateOn:["blur"], minValue:1900, maxValue:2010});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "integer", {minValue:1900, maxValue:2010, validateOn:["blur"], isRequired:false});
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "currency", {validateOn:["blur"], isRequired:false});
</script>
<br class="clearfloat" />
<!-- end #container -->
</div></div></div>
<script type="text/javascript">
<!--
var = new Spry.Widget.MenuBar("", {imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
var MenuBar2 = new Spry.Widget.MenuBar("MenuBar2", {imgDown:"../SpryAssets/SpryMenuBarDownHover.gif", imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"});
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
//-->
</script>
</body>
</html>
<?php
mysql_free_result($Advert);
if (is_resource($Result1)) mysql_free_result($Result1);
?>
Copy link to clipboard
Copied
Please note,
Removing I investigated spry a little more, in the end I settled for removing spry altogether,
Maybe it was because the text field in a $GET (for the default) AND a $PUT (for the update)