Trying to insert into 2 tables at same time?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jmansa
Forum Commoner
Posts: 81
Joined: Wed Aug 23, 2006 4:00 am

Trying to insert into 2 tables at same time?

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What's the problem?
jmansa
Forum Commoner
Posts: 81
Joined: Wed Aug 23, 2006 4:00 am

Post by jmansa »

It only inserts dat into the first table...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
jmansa
Forum Commoner
Posts: 81
Joined: Wed Aug 23, 2006 4:00 am

Post 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
Hemlata
Forum Commoner
Posts: 35
Joined: Mon Sep 10, 2007 5:40 am
Location: India
Contact:

Post 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,
Post Reply