hey all,
just trying to update some content that is loaded in from a database…yet when i type the new content to change in the form when i click update the old content is still displayed :S:S here is the php/html code:
<?php require_once('../Connections/cx.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 content SET home_main=%s WHERE id=%s",
GetSQLValueString($_POST['hcontentleft'], "text"),
GetSQLValueString($_POST['hcontentleft'], "int"));
mysql_select_db($database_cx, $cx);
$Result1 = mysql_query($updateSQL, $cx) or die(mysql_error());
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
$updateSQL = sprintf("UPDATE content SET home_main1=%s WHERE id=%s",
GetSQLValueString($_POST['hcontentright'], "text"),
GetSQLValueString($_POST['hcontentright'], "int"));
mysql_select_db($database_cx, $cx);
$Result1 = mysql_query($updateSQL, $cx) or die(mysql_error());
}
mysql_select_db($database_cx, $cx);
$query_home_contentleft = "SELECT home_main FROM content WHERE id = 6";
$home_contentleft = mysql_query($query_home_contentleft, $cx) or die(mysql_error());
$row_home_contentleft = mysql_fetch_assoc($home_contentleft);
$totalRows_home_contentleft = mysql_num_rows($home_contentleft);
mysql_select_db($database_cx, $cx);
$query_home_contentright = "SELECT home_main1 FROM content WHERE id = 7";
$home_contentright = mysql_query($query_home_contentright, $cx) or die(mysql_error());
$row_home_contentright = mysql_fetch_assoc($home_contentright);
$totalRows_home_contentright = mysql_num_rows($home_contentright);
?>
<?php require_once('../Connections/cx.php'); ?>
<title>Chilled Xzibits</title>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
left:205px;
top:106px;
width:600px;
height:28px;
z-index:1;
}
body {
background-color: #FFFFFF;
}
-->
</style>
<link href="../content.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
#Layer2 {
position:absolute;
left:214px;
top:312px;
width:360px;
height:102px;
z-index:1;
}
a:link {
text-decoration: none;
color: #000000;
}
a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: none;
color: #0066CC;
}
a:active {
text-decoration: none;
}
-->
</style>
<table width="100%" height="100%" border="0" align="center">
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td width="692" height="394" valign="top" background="../images/cxbackground.png"><table width="100%" height="390" border="0">
<!--DWLayoutTable-->
<tr>
<td height="33" align="right" valign="bottom"> <p> </p></td>
<td colspan="2" valign="bottom"><a href="../index.php"><img src="../images/home_over.png" alt="Home" width="54" height="26" border="0" /></a></td>
<td width="53" valign="bottom"><a href="../about.php"><img src="../images/about_over.png" alt="About" width="50" height="26" border="0" /></a></td>
<td width="59" valign="bottom"><img src="../images/services_over.png" alt="Services" width="57" height="26" /></td>
<td width="63" valign="bottom"><img src="../images/portfolio_over.png" alt="Portfolio" width="63" height="26" /></td>
<td colspan="2" valign="bottom"><a href="../contacts.php"><img src="../images/contacts_over.png" alt="Contacts" width="67" height="26" border="0" /></a></td>
<td width="284"> </td>
<td width="29"> </td>
</tr>
<tr>
<td width="26" height="282"> </td>
<td width="16"> </td>
<td colspan="5" valign="top"><p> </p>
<form action="<?php echo $editFormAction; ?>" method="POST" name="form1" class="content" id="form1">
<p align="left">Home Content Left:<br />
<textarea name="hcontentleft" cols="30" rows="4" id="hcontentleft"><?php echo nl2br ($row_home_contentleft['home_main']); ?></textarea>
<br />
<input name="Update" type="submit" id="Update" value="Update" />
<input type="hidden" name="MM_update" value="form1">
</p>
</form>
<p class="content"> </p>
</td>
<td width="21"> </td>
<td valign="top"><p> </p>
<form action="<?php echo $editFormAction; ?>" method="POST" name="form2" class="content" id="form2">
Home Content Right:<br />
<textarea name="hcontentright" cols="30" rows="4" id="hcontentright"><?php echo nl2br ($row_home_contentright['home_main1']); ?></textarea>
<br />
<input name="Update_right" type="submit" id="Update_right" value="Update" />
<input type="hidden" name="MM_update" value="form2">
</form> <p class="content"> </p></td>
<td> </td>
</tr>
<tr>
<td height="42" colspan="5"></td>
<td></td>
<td width="62"></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="15"></td>
<td></td>
<td width="34"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
<label></label></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<?php
mysql_free_result($Home_content);
mysql_free_result($home_contentleft);
mysql_free_result($home_contentright);
?>
if anyone has any ideas why it would be doing this would be great to hear from you!
p.s. i have checked the privileges for my user account on the database and i have all of them assigned so that shouldn’t be the problem
thanks peeps in advance