Jump to content

Recommended Posts

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:

wtf.gif

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>


Link to comment
https://forums.phpfreaks.com/topic/69945-mysql-update-prob/
Share on other sites

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


Link to comment
https://forums.phpfreaks.com/topic/69945-mysql-update-prob/#findComment-351364
Share on other sites

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...

Link to comment
https://forums.phpfreaks.com/topic/69945-mysql-update-prob/#findComment-351371
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/69945-mysql-update-prob/#findComment-351373
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.