Can't use function return value in write context

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mevets
Forum Newbie
Posts: 23
Joined: Fri Sep 15, 2006 10:06 am

Can't use function return value in write context

Post by mevets »

I have written a while loop that fetches data from a mysql query. On each iteration of the loop the data is saved to an array if it was not one of the pieces of data marked for deletion. If it was marked for deletion, then that row is deleted from the table.

Code: Select all

$i = 1;
while($row = mysql_fetch_assoc($result)) {
	if (!isset($_POST['btnunarchive'])) {
		if (!isset($_POST['chk' . $i])) {
			$noteinfo[--$i]['note'] = $row['note'];
			$noteinfo[--$i]['author'] = $row['author'];
			$noteinfo[--$i]['time'] = $row['time'];
		}
	}
	elseif (isset($_POST['btnunarchive'])) {
		if (isset($_POST('chk' . $i))) {
			$qunarchive = "DELETE FROM archive WHERE id = $row['id']";
			$uaresult = mysql_query($qunarchive);
			echo 'Note ' . $row['$id'] . 'was deleted.<br />';
		}
	}
	$i++
}
When this code is ran I get
Fatal error: Can't use function return value in write context in /var/www/workspace/notes/archive.php on line 101
Line 101 is

Code: Select all

if (isset($_POST('chk' . $i))) {
What exactly have I done wrong? Also, I am most likely wrong, but in the error message does it mean 'right' as in correct instead of write (just think that'd be a humorous bug)?
mevets
Forum Newbie
Posts: 23
Joined: Fri Sep 15, 2006 10:06 am

Post by mevets »

Sorry, figured out that I should be using [] instread of ().
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

How about editing the original title and add [SOLVED] to the beginning of it?
Post Reply