homepage Welcome to WebmasterWorld Guest from 54.242.200.172
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderators: physics

Databases Forum

    
having troubles inserting values in two different tables
inserting values into tb_users and wp_users
HitDelisi




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

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




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

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




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

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




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

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




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

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




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

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




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

oh thank you very much it really worked :)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved