0

I have two tables ("members", "ban"). I'm trying to insert a row into "ban" while at the same time update "members", but it won't allow me. The query fails when I run it on my website (though it works when I execute them individually) but this code works outside of my website (for instance, phpMyAdmin's SQL code executor).

INSERT INTO `ban` ( `mid`, `note`, `date` )
VALUES ( 51, "Test note", "0-0-0 0:0:0" );
UPDATE `members`
SET `banned` = 1
WHERE `id` = 51

Could it be something in my PHP config file? Thanks.

Edit: I'm running it with a MySQLi object, like so

$mysqli->query('
    INSERT INTO `ban` ( `mid`, `note`, `date` )
    VALUES ( 51, "Test note", "0-0-0 0:0:0" );
    UPDATE `members`
    SET `banned` = 1
    WHERE `id` = 51
');

Also, as a side note, is this code considered two queries? I'm limited to 75,000 queries an hour so I'm trying to limit my queries. Thanks.

Tom
  • 207
  • 2
  • 18
  • 3
    How are you running it? Please, provide the error too... (assuming you are using mysqli, take a look at [http://php.net/manual/en/mysqli.multi-query.php](http://php.net/manual/en/mysqli.multi-query.php), if not, just ignore). – FirstOne Nov 21 '15 at 23:55
  • @FirstOne: Updated! I'm afraid I'm not getting a specific error, just a generic unspecified one. And thanks, I'll take a look. – Tom Nov 22 '15 at 00:01
  • 1
    Ok, let us know if the provided [link](http://php.net/manual/en/mysqli.multi-query.php) solves it ^^. About the last question: I can't really say anything because I don't want to give you any misleading information. – FirstOne Nov 22 '15 at 00:02
  • @FirstOne: Oh I see! So I can't do it directly. Thank you! I've been using MySQL for over two years but this is the first time I heard about this lol – Tom Nov 22 '15 at 00:06
  • 1
    Since this has already been answered: [Two mysqli queries](http://stackoverflow.com/questions/10924127/two-mysqli-queries). The other topic (query limit) I really don't know ^^ – FirstOne Nov 22 '15 at 00:09

0 Answers0