0

I have this code on my PHP:

$query = "DELETE FROM ponteved_admincs." . $_GET['servidor'] . " WHERE auth = '" . $_GET['auth'] . "';UPDATE ponteved_foroipb.members SET member_group_id = 3 WHERE member_id = '" . $_GET['foroid'] . "' LIMIT 1";
mysqli_multi_query($con,$query);

This code removes from DB the specified user passed by a GET, and changes user groups on the IPB forum. Is there a way to do variables in a query if I try to do it on a MYSQL EVENT?

I have this on a MysqlEVENT:

DELETE FROM ponteved_admincs.27015 WHERE DATE(vencimiento) <= DATE(NOW())

Example that I'd like to do, but I don't know:

var @getuserid = SELECT `foroid` FROM `27015` WHERE `auth` = 'Green';
DELETE FROM ponteved_admincs.27015 WHERE DATE(vencimiento) <= DATE(NOW())
UPDATE ponteved_foroipb.members SET member_group_id = 3 WHERE member_id = '@getuserid'

Thanks!

Fulbito
  • 7
  • 7
  • 3
    [Little Bobby Tables](http://xkcd.com/327/) – Mark Baker Jan 31 '14 at 14:57
  • You should prepare the statement first, otherwise you are open to SQL injection. @MarkBaker lol –  Jan 31 '14 at 14:57
  • what exactly you want to do please explain – Aitazaz Khan Jan 31 '14 at 14:58
  • 1
    [Identifiers may begin with a digit but unless quoted may not consist solely of digits.](http://dev.mysql.com/doc/refman/5.6/en/identifiers.html) – Mark Baker Jan 31 '14 at 14:58
  • I'm only the person that have access to the form. I'm trying to remove expire data to db automatically, and change user groups on the related forum, but I need the user ID of the forum (found in a column). – Fulbito Jan 31 '14 at 15:04
  • Are you trying to do this in a mysql function / stored procedure? – Kickstart Jan 31 '14 at 15:07
  • Yes, via Mysql Event automatically. – Fulbito Jan 31 '14 at 15:11
  • 1
    You can use CONCAT to build up a string which you then use prepare to use the string as a statement, then execute the statement. Check the 2nd response to this question - http://stackoverflow.com/questions/190776/how-to-have-dynamic-sql-in-mysql-stored-procedure – Kickstart Jan 31 '14 at 15:21

0 Answers0