Page 1 of 1

Trying to insert into 2 tables at same time?

Posted: Thu Oct 04, 2007 3:48 am
by jmansa
I cant figure out where I'm going wrong... I'm trying to insert data into 2 different tables at the same time?

My code looks like this:

Code: Select all

$cluid = $db->GenID (cms_db_prefix ()."module_clubmanager_clubs_seq");
	    $query = "INSERT INTO ".cms_db_prefix ()."module_clubmanager_clubs VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
	    $dbresult = $db->Execute ($query, array ($cluid,
				   $params["input_clubid"],
				   $params["input_nation"],
				   $params["input_letter"],
				   $params["input_clubname"],
				   $params["input_clubalias"],				  
				   $params["input_password"],
				   $params["input_18"],
				   $params["input_18_9"],
				   $params["input_27"],
				   $params["input_36"],
				   $params["input_9"],
				   $params["input_adress1"],
				   $params["input_adress2"],
				   $params["input_adress3"],
				   $params["input_zipcity"],
				   $params["input_phone"],
				   $params["input_fax"],
				   $params["input_email"],
				   $params["input_homepage"]));
				   
		$infoid = $db->GenID (cms_db_prefix ()."module_clubmanager_clubinfo_seq");
	    $query = "INSERT INTO ".cms_db_prefix ()."module_clubmanager_clubinfo VALUES (?,?,?,?,?)";
	    $dbresult = $db->Execute ($query, array ($infoid, 
				$params["input_clubid"], 
				$params["input_nation"], 
				$params["input_clubname"], 
				$params["input_clubalias"], 
				$params["input_password"]));
				   
	    if (!$dbresult) {
  	    	echo $db->ErrorMsg();
      		return;
			}		

    	if ($error) {
			echo $this->ProcessTemplate ('addclub.tpl');
        	}
    	else {
			$this->Redirect ($id, 'defaultadmin', $returnid);
     		}
Can somebody please help?

Posted: Thu Oct 04, 2007 8:05 am
by feyd
What's the problem?

Posted: Thu Oct 04, 2007 9:37 am
by jmansa
It only inserts dat into the first table...

Posted: Thu Oct 04, 2007 9:43 am
by feyd
Could it be because you have five places marked in the second query, but pass six?

Are you getting an error? If so, post it.

Posted: Thu Oct 04, 2007 12:51 pm
by jmansa
Asfar as I can see I only passes 5 places! I dont get any error, it just returns without any error... Its driving me crazy... HEEELP

Posted: Fri Oct 05, 2007 12:39 am
by Hemlata
Hello,

I too agree with 'Feyed' that you have marked 5 places and passing 6 values. See your code below..

Code: Select all

$query = "INSERT INTO ".cms_db_prefix ()."module_clubmanager_clubinfo VALUES (?,?,?,?,?)"; // 5 places marked

$dbresult = $db->Execute ($query, array ($infoid,
                                $params["input_clubid"],
                                $params["input_nation"],
                                $params["input_clubname"],
                                $params["input_clubalias"],
                                $params["input_password"])); // 6 values passed in the array
Hope this might solve your issue.
Regards,