If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Insert Query Returns False

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-10-09, 13:24
Schweppesale Schweppesale is offline
Registered User
 
Join Date: Jun 2009
Posts: 33
Insert Query Returns False

Not sure where I'm screwing up here. I'll post the database schema if it's not obvious, for some reason the fourth query returns false though.

Code:
 $query = "INSERT INTO jos_users 
	   (name, usertype, username, email, password, registerDate, gid, sendEmail, block, params, lastvisitDate) 
	VALUES 
	   ('".$name."', 'Registered', '".$username."', '".$email."', '".$password."', '".$date."', '18', '0', '0', '".$params."', '".$date."')";
   
   
	   $query2 = "INSERT INTO jos_core_acl_aro (id, section_value, value, order_value, name, hidden) 	
	 VALUES (NULL, 'users', LAST_INSERT_ID(), '0', '".$name."', '0')";
 
	   $query3 = "INSERT INTO jos_core_acl_groups_aro_map VALUES (18, '', LAST_INSERT_ID())";
	  
	   $query4 = "INSERT INTO jos_comprofiler
	   (id, user_id, firstname, lastname, hits, message_last_sent, message_number_sent, avatar, avatarapproved, approved, confirmed, lastupdate, registeripaddr, banned)  
	 VALUES (NULL, LAST_INSERT_ID(), '".$fname."', '".$lname."', '0', '0000-00-00 00:00:00', '0', NULL, '1', '1', '1', '0000-00-00 00:00:00', '".$ip_addr."', '0')";
	   
 
	   $query = mysql_query($query);
	   $query2 = mysql_query($query2);
	   $query3 = mysql_query($query3);
	   $query4 = mysql_query($query4);
keep in mind that I'm leaving quite a few values out, that shouldn't matter though since I'm specifying which columns to add the data to correct?
Reply With Quote
  #2 (permalink)  
Old 11-10-09, 13:51
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Why not show us what's actually being executed and what the error message says. It's good practise to do this for all database queries:
Code:
$query4 = mysql_query($query4) or die($query4 . " -> " . mysql_error());
Reply With Quote
  #3 (permalink)  
Old 11-10-09, 13:54
Schweppesale Schweppesale is offline
Registered User
 
Join Date: Jun 2009
Posts: 33
thanks, i actually wasn't sure how to do that. Let me see if I can figure it out.
Reply With Quote
  #4 (permalink)  
Old 11-10-09, 23:53
ameyer ameyer is offline
Registered User
 
Join Date: Jul 2009
Posts: 32
The easy fix...

echo $query;

paste that into phpmyadmin OR just look at it and see if it looks weird. Easiest way to see if it is your PHP or your query.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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