Welcome to WebmasterWorld Guest from 107.20.34.173

Forum Moderators: open

Message Too Old, No Replies

having troubles inserting values in two different tables

inserting values into tb_users and wp_users

     

HitDelisi

3:43 pm on Feb 9, 2010 (gmt 0)

5+ Year Member



hi all. in my registration form, i want to insert informations into two different tables. these two tables are in the same databases. first one's name is tb_users, second one's name is wp_users.

i think this part is about inserting ;

$sqlz = "SELECT * FROM tb_users WHERE username='$referer'";
$resultz = mysql_query($sqlz);
$myrowz = mysql_fetch_array($resultz);

$numero=$myrowz["referals"];

$sqlex = "UPDATE tb_users SET referals='$numero'+1 WHERE username='$referer'";
$resultex = mysql_query($sqlex);
}

}


// Si todo parece correcto procedemos con la inserccion

$joindate=time();

$query = "INSERT INTO tb_users (username, password, ip, email, pemail, referer, country, joindate, money,visits) VALUES('$username','$password','$laip','$email','$pemail','$referer','$country','$joindate', '0', '0')";
mysql_query($query) or die(mysql_error());

echo "registered as <strong><b>$username</b></strong>";


now here, it inserts '$username','$password' values into tb_users->username, password

and i want to insert these '$username','$password' into wp_users->user_login,user_pass too. my aim is to let visitors register for one site and have account in two other sites. i have changed this section


PHP Kodu:
$query = "INSERT INTO tb_users (username, password, ip, email, pemail, referer, country, joindate, money,visits) VALUES('$username','$password','$laip','$email','$pemail','$referer','$country','$joindate', '0', '0')";
mysql_query($query) or die(mysql_error());

with this one

PHP Kodu:
$query = "INSERT INTO tb_users (username, password, ip, email, pemail, referer, country, joindate, money,visits) VALUES('$username','$password','$laip','$email','$pemail','$referer','$country','$joindate', '0', '0')";
$query = "INSERT INTO wp_users (user_login, user_pass) VALUES('$username','$password')";
mysql_query($query) or die(mysql_error());

but it still gave errors. i am not an experienced mysql man :) so it might be very easy for you to solve. i am thanking in advance to whom will help me with this. have a great day...

[edited by: jatar_k at 10:23 pm (utc) on Feb 10, 2010]
[edit reason] no urls thanks [/edit]

LifeinAsia

4:26 pm on Feb 9, 2010 (gmt 0)

WebmasterWorld Administrator lifeinasia is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



Welcome to WebmasterWorld [webmasterworld.com], HitDelisi!

As you should know from reading the Terms of Service, you are not supposed to post URLs. (The mods will most likely clean it up soon.)

but it still gave errors

What errors? Knowing the error message(s) goes a long way towards diagnosing and fixing the problem.

Without knowing PHP, I am guessing that only the second query is being executed, since I don't see any mysql_query($query) executed before the second one is specified. This may or may not have anything to do with the error(s) you are receiving.

HitDelisi

4:36 pm on Feb 9, 2010 (gmt 0)

5+ Year Member



this is the code :

$query = "INSERT INTO tb_users (username, password, ip, email, pemail, referer, country, joindate, money,visits) VALUES('$username','$password','$laip','$email','$pemail','$referer','$country','$joindate', '0', '0');
INSERT INTO wp_users (user_login, user_pass) VALUES('$username','$password');";
mysql_query($query) or die(mysql_error());


and this is the error message


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 'INSERT INTO wp_users (user_login, user_pass) VALUES('ultraslan','1111aa')' at line 2

LifeinAsia

4:43 pm on Feb 9, 2010 (gmt 0)

WebmasterWorld Administrator lifeinasia is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



What are the field types for user_login and user_pass? Are there any other fields in the wp_users table and are they all nullable?

HitDelisi

5:05 pm on Feb 9, 2010 (gmt 0)

5+ Year Member



user_login varchar(60)
user_pass varchar(64)

here are the pictures

wp_users

tb_users

[edited by: jatar_k at 10:24 pm (utc) on Feb 10, 2010]

LifeinAsia

5:13 pm on Feb 9, 2010 (gmt 0)

WebmasterWorld Administrator lifeinasia is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



Just for fun, try something like:
$query = "INSERT INTO tb_users (username, password, ip, email, pemail, referer, country, joindate, money,visits) VALUES('$username','$password','$laip','$email','$pemail','$referer','$country','$joindate', '0', '0');";
mysql_query($query) or die(mysql_error());
$query = "INSERT INTO wp_users (user_login, user_pass) VALUES('$username','$password');";
mysql_query($query) or die(mysql_error());

HitDelisi

5:25 pm on Feb 9, 2010 (gmt 0)

5+ Year Member



oh thank you very much it really worked :)
 

Featured Threads

Hot Threads This Week

Hot Threads This Month