Jump to content

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);

 

 

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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