[SOLVED] tutorial delete multiple rows code not working

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

reecec
Forum Contributor
Posts: 218
Joined: Sun Apr 02, 2006 7:12 am

Post by reecec »

sorted thanks to all that helped me
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

The sql statement is prone to sql injections, see http://en.wikipedia.org/wiki/SQL_injection
better use

Code: Select all

$ids = join(',', array_map('intval', $_POST['checkbox']));
$query = "DELETE
		FROM
			`$tbl_name`
		WHERE
			`id` IN($ids)";
$result = mysql_query($query) or die(mysql_error($link). ': '.$query);
Post Reply