//write the query to update $sql = "UPDATE " . DB_PREFIX . "index SET indextitle='$indextitle', indexcontent='$indexcontent', indeximage='$indeximage' WHERE indexid=1";
//perform the query $result = mysql_query($sql);
//if there was an error... if(!$result) { echo('Error updating database ' . mysql_error()); }
}
CODE
//if the user has edited the content, deal with it if($_GET['do'] == "update") {
//write the query to update $sql = "UPDATE " . DB_PREFIX . "index SET indexid=2, indextitle='$indextitle', indexcontent='$indexcontent', indeximage='$indeximage' WHERE indexid=1";
//perform the query $result = mysql_query($sql);
//if there was an error... if(!$result) { echo('Error updating database ' . mysql_error()); }
}
The first doesn't update the database, the second does. Why would it matter if I am updating the indexid or not? there will only ever be one entery in this table, and it will just get updated all the time.
When the table is updated to have index id of 2, if you change the where clause to say 2, it wont update, until you change the number of the indexid.
It is so random. Any thoughts before i go and kick myself? /sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" />
help!!!
I have been trying for 1.5hrs to sort out what shouldn't be a problem in the first place.
take the following 2 samples of code:
if($_GET['do'] == "update") {
//get the posted variables
$indextitle = $_POST['indextitle'];
$indexcontent = $_POST['indexcontent'];
$indeximage = $_POST['SelectImage'];
//write the query to update
$sql = "UPDATE " . DB_PREFIX . "index SET indextitle='$indextitle', indexcontent='$indexcontent', indeximage='$indeximage' WHERE indexid=1";
//perform the query
$result = mysql_query($sql);
//if there was an error...
if(!$result) {
echo('Error updating database ' . mysql_error());
}
}
if($_GET['do'] == "update") {
//get the posted variables
$indextitle = $_POST['indextitle'];
$indexcontent = $_POST['indexcontent'];
$indeximage = $_POST['SelectImage'];
//write the query to update
$sql = "UPDATE " . DB_PREFIX . "index SET indexid=2, indextitle='$indextitle', indexcontent='$indexcontent', indeximage='$indeximage' WHERE indexid=1";
//perform the query
$result = mysql_query($sql);
//if there was an error...
if(!$result) {
echo('Error updating database ' . mysql_error());
}
}
The first doesn't update the database, the second does. Why would it matter if I am updating the indexid or not? there will only ever be one entery in this table, and it will just get updated all the time.
When the table is updated to have index id of 2, if you change the where clause to say 2, it wont update, until you change the number of the indexid.
It is so random. Any thoughts before i go and kick myself?
/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" />
Patrick TT
Aussie Freelancer | Impact Shrewsbury