Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   eCommerce & Atahualpa (http://forum.bytesforall.com/forumdisplay.php?f=31)
-   -   Write to a database table (http://forum.bytesforall.com/showthread.php?t=5706)

joan Feb 4, 2010 03:42 AM

Write to a database table
 
Hi JuggleDad
I am using Simple Paypal Shopping Cart, but I need to collect some extra client info before they check out. Into the Simple php file which displays the checkout page, within a form, I added two input boxes, as below:
`<form action="http://www.travelhorizonstyle.com.au/wp-content/cust-write.php" method="post" name="book"><input type="text" size="10" value="" name="First"><br><input type="text" size="10" value="" name="Last"><input type="submit" value="NEXT"></form>';`

Into the cust-write.php file I have tried various methods to get these two fields to be written to the database, without success as I keep getting an error about and invalid object... The variations are commented out below:

`<?php
function save() {
global $wpdb;
$key1 = "user_login";
$key1 = "user_nicename";
$First = $_POST['First'];
$Last = $_POST['Last'];
$result = $wpdb->query( $wpdb->prepare( "INSERT INTO {$wpdb->customers} ( user_login, user_nicename ) VALUES ( %s, %s )", $First, $Last ) );
//$wpdb->insert( 'table', array( 'column1' => 'value1', 'column2' => 123 ), array( '%s', '%d' ) )
//$wpdb->insert( $wpdb->customers, array( user_login => $First, user_nicename => $Last ) );
//$wpdb->query( $wpdb->prepare( " INSERT INTO $wpdb->customers ( $key1, $key2 ) VALUES ( %s, %s )", $First, $Last ));
//$wpdb->query( $wpdb->prepare( " INSERT INTO $wpdb->customers ( user_login, user_nicename ) VALUES test, tester ));
//$wpdb->query("INSERT INTO $wpdb->customers VALUES(" .$First .",". $Last . ")");
$wpdb->flush();
//Parse error: syntax error, unexpected T_OBJECT_OPERATOR i
//Call to a member function insert() on a non-object in..line 7
//Call to a member function query() on a non-object in.. line 8
//return $result;
}
?> `

Can you or any of the wonderful friends of Atahualpa give me suggestions as to why it will not write the the database table 'customers' ??

Kind regards,
Joan.


All times are GMT -6. The time now is 01:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.