PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Linx
Forum Newbie
Posts: 3 Joined: Thu Feb 03, 2011 8:36 am
Post
by Linx » Thu Feb 03, 2011 8:42 am
Hello. How to edit my script to insert data to two different table?
Here's my query:
Code: Select all
$query = mysql_query("SELECT * FROM users WHERE username = '$text'") or die(mysql_error());
if(mysql_num_rows($query)) {
echo "That user already exist!";exit;
}
mysql_query("INSERT INTO users (username, password, points) VALUES ('$text','$pass','$points')");
MindOverBody
Forum Commoner
Posts: 96 Joined: Fri Aug 06, 2010 9:01 pm
Location: Osijek, Croatia
Post
by MindOverBody » Thu Feb 03, 2011 9:20 am
You cant insert data into two table within one query. You must make two separate queries to do it.
Code: Select all
mysql_query("INSERT INTO table1 (column) VALUES (data)");
mysql_query("INSERT INTO table2 (column) VALUES (data)");