ccrevcypsys Posted September 19, 2007 Share Posted September 19, 2007 well i am trying to be able to change a 0 to a 1 on the deleted column. but when i click the submit button it does this: and i need all of the info to stay there here is the code Php <?php //Under this the assign-> tells ID to do , $this and puts it on tpl page $artist_console->assign("ID",$members_loop[$i]['id']); if(isset($_POST['deleted'])) { $id = ($_POST['id']); $record["deleted"] = $db->mySQLSafe($_POST['deleted']); $record["id"]= $db->mySQLSafe($_POST['id']); $where = "id = ".$db->mySQLSafe($_POST['id']); $insert = $db->update($glob['dbprefix']."StreamRush_bandinfo", $record , $where); } ?> Html <form name="delete" action="index.php?act=artistConsole&members=members#content" enctype="multipart/form-data" method="post"> <input name="deleted" type="hidden" class="textbox" value="1"> <!-- {ID} = the assign function that is in php code --> <input name="id" class="textbox" value="{ID}" /> <input name="submit" type="submit" value="Delete" class="submit" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/69945-mysql-update-prob/ Share on other sites More sharing options...
BlueSkyIS Posted September 19, 2007 Share Posted September 19, 2007 need to see code for $db->update Quote Link to comment https://forums.phpfreaks.com/topic/69945-mysql-update-prob/#findComment-351360 Share on other sites More sharing options...
ccrevcypsys Posted September 19, 2007 Author Share Posted September 19, 2007 The song menu has the same system. I can delete a song and it only changes a 0 to a 1 i dunno why this isnt working the same way they are both the same code (on diff pages and different values but same none the less) so i dont know if it would be this. function update ($tablename, $record, $where) { if(!is_array($record)) die ($this->debug("array", "Update", $tablename)); $count = 0; foreach ($record as $key => $val) { if ($count==0) $set = "`".$key."`"."=".$val; else $set .= ", " . "`".$key."`". "= ".$val; $count++; } $query = "UPDATE ".$tablename." SET ".$set." WHERE ".$where."; "; $this->query = $query; mysql_query($query, $this->db); if ($this->error()) die ($this->debug()); if ($this->affected() > 0) return true; else return false; } // end update function NewUpdate($tablename, $record, $where) { if(!is_array($record)) die($this->debug("array", "Update", $tablename)); if(empty($tablename)) die("tablename not set '$tablename'"); if(empty($where)) die("where not set '$where'"); $set = ""; foreach ($record as $key => $val) { $set .= "`$key` = $val,"; } $set= trim($set,","); $query = "UPDATE $tablename SET $set WHERE $where; "; $this->query = $query; mysql_query($query, $this->db); if ($this->error()) die ($this->debug()); if ($this->affected() > 0) return true; else return false; } // end update Quote Link to comment https://forums.phpfreaks.com/topic/69945-mysql-update-prob/#findComment-351364 Share on other sites More sharing options...
BlueSkyIS Posted September 19, 2007 Share Posted September 19, 2007 what's going on in the form here? <input name="id" class="textbox" value="{ID}" /> is ID supposed to be something more like <?=$ID;?> ?? If you're not passing an ID, hence you're passing "", then you're passing that ID to the UPDATE, you may be trying to UPDATE table SET ID = '' WHERE ID = '' or something odd... Quote Link to comment https://forums.phpfreaks.com/topic/69945-mysql-update-prob/#findComment-351371 Share on other sites More sharing options...
ccrevcypsys Posted September 19, 2007 Author Share Posted September 19, 2007 no my class states that anything in {} will reffer to what it says in the {} ex on the members.inc.php it says $artist_console->assign("ID",$members_loop[$i]['memberId']); on the members.tpl it says <input name="id" class="textbox" value="{ID}" /> and it is showing up on the form for the right one. It is even updating the right row but it erases everything in the column except for the image and memberId Quote Link to comment https://forums.phpfreaks.com/topic/69945-mysql-update-prob/#findComment-351373 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.