Current location: Hot Scripts Forums » Other Discussions » Database » mysql insert problem


mysql insert problem

Reply
  #1 (permalink)  
Old 07-20-06, 02:59 PM
zoliky's Avatar
zoliky zoliky is offline
Aspiring Coder
 
Join Date: Jun 2006
Posts: 537
Thanks: 0
Thanked 0 Times in 0 Posts
mysql insert problem

PHP Code:

// Check if user exist in db

$find_username mysql_query("SELECT user_id,username FROM register WHERE username = '".varCheck($_POST['username'])."'");
$duplicate_username mysql_num_rows($find_username);
$uid mysql_fetch_array($find_username);

// Check if email exist in db
$find_email mysql_query("SELECT email FROM register WHERE email = '".varCheck($_POST['email'])."'");
$duplicate_email mysql_num_rows($find_email);

if (isset (
$_POST['submit'])) {

$problem FALSE;    

  if (empty (
$_POST['username'])) {
  
$problem['username'] = TRUE;
  print 
"<p>Please type a username</p>\n";
  }

  if ( (
$duplicate_username )) {
  
$problem['username'] = TRUE;
  print 
"<p>The username already exist in database!</p>\n";
  }

  if ( (
$duplicate_email )) {
  
$problem['email'] = TRUE;
  print 
"<p>The email address already exist in database!</p>\n";
  }

if (!
$problem) {
   if ((
$duplicate_username == ) && ($duplicate_email == 0)) {
   
mysql_query ("INSERT INTO register (user_id, username, password, email, validate, forgetpwd, date_entered) VALUES (0, '".varCheck($_POST['username'])."', '".crypt($_POST['password'],"{$_POST['username']}")."', '".varCheck($_POST['email'])."', '".sha1($_POST['username']. time())."', '0', NOW())") or die (mysql_error());
   
mysql_query ("INSERT INTO user2groups (uid) VALUES ('".$uid['user_id']."')"); 
I want to insert the added user "user_id" to user2groups table, the following line do this :

PHP Code:

mysql_query ("INSERT INTO user2groups (uid) VALUES ('".$uid['user_id']."')"); 

But I don't get the user_id value

Any idea or suggestion ?

Last edited by nico_swd; 07-20-06 at 04:53 PM. Reason: Replaced code with php wrappers.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Auto Dealer Script nuzzle PHP 17 04-14-10 08:34 PM
mysql insert problem loeddie PHP 13 02-18-05 03:04 AM
Problem with Insert in MySql bionicsamir PHP 2 01-02-05 08:08 PM
MySQL Problem. landboy PHP 2 08-11-04 12:46 PM
Load Data Infile Problem (MySQL) Shaky2 PHP 1 03-26-04 04:48 PM


All times are GMT -5. The time now is 04:55 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.