Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2009
    Posts
    33

    Unanswered: 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?

  2. #2
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    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());

  3. #3
    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.

  4. #4
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •