Jump to content

Multiple queries to save server resources?


gergy008

Recommended Posts

Hi, I need to run two different queries...

 

Here is my Query:

 

INSERT INTO banning (`user`, `type`, `until`, `note`) VALUES ('$user', '$bantype', '$stamp', '$note'); UPDATE `users` SET `banned`='1' WHERE `login`='$user';

 

But it doesn't work... It dies as:

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE `users` SET `banned`='1' WHERE `login`='--User--'' at line 1

Hi, I need to run two different queries...

Run as two single queries:

 

$sql = "INSERT INTO banning (`user`, `type`, `until`, `note`) VALUES ('$user', '$bantype', '$stamp', '$note')";
$result = mysql_query($sql);
$sql="UPDATE `users` SET `banned`='1' WHERE `login`='$user'";
$result = mysql_query($sql);

 

 

Hi, I need to run two different queries...

Run as two single queries:

 

$sql = "INSERT INTO banning (`user`, `type`, `until`, `note`) VALUES ('$user', '$bantype', '$stamp', '$note')";
$result = mysql_query($sql);
$sql="UPDATE `users` SET `banned`='1' WHERE `login`='$user'";
$result = mysql_query($sql);

 

So you can't migrate 2 different queries and run it as a single query?

So you can't migrate 2 different queries and run it as a single query?
No, it's a protection against sql injection

 

If you run as two separate queries, it'll be easier for you to identify any problems, and easier to maintain... especially if you have proper error trapping.

 

You can execute multiple queries with mysqli

Archived

This topic is now archived and is closed to further replies.

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