You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 331 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
Nuke Cops :: View topic - Some SQL troubles [ ]
 Forum FAQ  •  Search  •   •  Memberlist  •  Usergroups   •  Register  •  Profile •    •  Log in to check your private messages  •  Log in

 
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
Author Message
Dommage
Nuke Cadet
Nuke Cadet


Joined: Dec 15, 2005
Posts: 2


PostPosted: Tue Dec 20, 2005 7:42 am Reply with quoteBack to top

Hey guys... I'm sure I'm making some noob mistake with this, it's been years since I've done much coding, but any help I could get would be greatly appreciated Wink

I'd trying to fill in a few extras tables when a user verifies their account. I hunted down
Code:
$db->sql_query("INSERT INTO ".$user_prefix."_users (user_id, username, user_email, user_password, user_avatar, user_avatar_type, user_regdate, user_lang) VALUES (NULL, '$row[username]', '$row[user_email]', '$row[user_password]', 'gallery/blank.gif', 3, '$row[user_regdate]', '$language')");

$db->sql_query("DELETE FROM ".$user_prefix."_users_temp WHERE username='$username' AND check_num='$check_num'");

in the modules/Your_Account/index.php file, and afterwards added
Code:
$db->sql_query("INSERT INTO eqdkp_users (user_id, username, user_password, user_email, user_alimit, user_elimit, user_ilimit, user_nlimit, user_rlimit, user_lang, user_style, user_key, user_lastvisit, user_lastpage, user_active, user_newpassword) VALUES (NULL, '$row[username]', '$row[user_password]', '$row[user_email]', 100, 100, 100, 10, 100, 11, 'english', NULL, 0, NULL, '1', NULL)");


This part works fine. What I want to do next is giving me some problems. I want to pull the user_id out of the eqdkp_users table for the record I just created, and then create an entry in the eqdkp_auth_users table that includes it.

First, I tried
Code:
$dkpid = $db->insert_id();
$db->sql_query("INSERT INTO eqdkp_auth_users (user_id, auth_id, auth_setting) VALUES ('$dkpid', 25, 'Y')");


No luck. It still inserted values into the table, but always used a user_id of 0. I then tried replacing the insert_id with
Code:
$dkpid = $db->sql_query("SELECT user_id FROM eqdkp_users WHERE username = '$username'");


and still get the same issue - it inserts a record, but always uses 0 as the user_id.

Any idea what I'm missing here?
Find all posts by DommageView user's profileSend private message
Prophet
Captain
Captain


Joined: Mar 14, 2004
Posts: 422

Location: Florida, USA, Earth, Space

PostPosted: Tue Dec 20, 2005 10:43 am Reply with quoteBack to top

Try this after the user has been inserted ...
Code:
$result = $db->sql_query("SELECT user_id FROM eqdkp_users ORDER BY user_id DESC");
$row = $db->sql_fetchrow($result);
$last_id = $row[user_id];


Then use $last_id wherever it's needed.

_________________
- Prophet
Get the Last Visit module (and others modules I designed) from my website! FREE! http://jasonlau.biz

http://DotCom.Name
Find all posts by ProphetView user's profileSend private messageVisit poster's websiteAIM Address
Dommage
Nuke Cadet
Nuke Cadet


Joined: Dec 15, 2005
Posts: 2


PostPosted: Tue Dec 20, 2005 8:27 pm Reply with quoteBack to top

Thanks Prophet, worked like a charm!

And with that, the last of my "high priority - must complete before going live" tasks is scratched off the list Very Happy
Find all posts by DommageView user's profileSend private message
Display posts from previous:      
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2005 phpBB Group

Ported by Nuke Cops © 2003 www.nukecops.com
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::
Powered by TOGETHER TEAM srl ITALY http://www.togetherteam.it - DONDELEO E-COMMERCE http://www.DonDeLeo.com - TUTTISU E-COMMERCE http://www.tuttisu.it
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.056 Seconds - 337 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::