PDA

View Full Version : Is my syntax correct?


SpeedStreet
11-04-2003, 08:32 PM
I'm trying to create a query that will insert information into different tables at the same time, is my code right, or do I need to alter it?

Thanks!

$insertSQL = sprintf("INSERT INTO forums_user (userid, username, password, salt, options, joindate, usergroupid) VALUES (%s, %s, '" . addslashes(md5(md5($_POST['password']) . $asalt)) . "','" . addslashes($asalt) . "','0','$today','2')",
GetSQLValueString($_POST['userid'], "int"),
GetSQLValueString($_POST['username'], "text"),
("INSERT INTO forums_usertextfield (userid) VALUES ('" . addslashes($_POST['userid']) . "')"),
("INSERT INTO forums_userfield (userid) VALUES ('" . addslashes($_POST['userid']) . "')")
);

KuraFire
11-04-2003, 10:41 PM
doing INSERTs in multiple tables is really just doing multiple different queries, and as such you should really just do separate queries.

It won't save you any speed or overhead by trying to fake them as one query, not just because that can't really be done, but also because that's not a real way of optimizing queries. :)

So, just run different insert queries and run them separately. :)