jim.davidson Posted April 4, 2007 Share Posted April 4, 2007 First I'm using PHP 5.0, mySQL 4.1.21 and Dreamweaver8 Here's what I'm trying to do ol-line customer fills out a form for contact information. I save this to session variables. Customer goes to next page adds item(s) to cart then goes to checkout page. At this point I'm sure I got a customer so I want to add the session info into a table called customers. I then need to capture the customer id from the insert so that I can add it to the orders table(next step if I ever get through this step) Here's my code for the insert(doesn't work) would appreciate any help //WA eCart Redirect Check Out if (isset($_POST["Recycle_Checkout_1"]) || isset($_POST["Recycle_Checkout_1_x"])) { $Redirect_redirStr="test_checkout.php"; // place insert customer info here $insertSQL = sprintf("INSERT INTO customers (first_name, last_name, address_1, address_2, city, state, zip, contact_name, contact_phone, contact_email, contact_comments) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_SESSION['contact_first_name'], "text"), GetSQLValueString($_SESSION['contact_last_name'], "text"), GetSQLValueString($_SESSION ['conntact_address1'], "text"), GetSQLValueString($_SESSION ['contact_address2'], "text"), GetSQLValueString($_SESSION ['contact_city'], "text"), GetSQLValueString($_SESSION ['contact_state'], "text"), GetSQLValueString($_SESSION ['contact_zip'], "text"), GetSQLValueString($_SESSION['contact_name'], "text"), GetSQLValueString($_SESSION['contact_phone'], "text"), GetSQLValueString($_SESSION['contact_email'], "text"), GetSQLValueString($_SESSION['contact_comments'], "text")); $_SESSION['cust_id'] = mysql_insert_id(); mysql_select_db($database_imcrecycle, $imcrecycle); $Result1 = mysql_query($insertSQL, $imcrecycle) or die(mysql_error()); // end of insert Link to comment https://forums.phpfreaks.com/topic/45576-solved-help-needed-with-insert/ Share on other sites More sharing options...
kenrbnsn Posted April 4, 2007 Share Posted April 4, 2007 "Doesn't work" covers a lot of ground. How doesn't it work? Do you get any errors? Ken Link to comment https://forums.phpfreaks.com/topic/45576-solved-help-needed-with-insert/#findComment-221309 Share on other sites More sharing options...
jim.davidson Posted April 4, 2007 Author Share Posted April 4, 2007 Sorry here's the error Fatal error: Call to undefined function GetSQLValueString() in C:\Sites\test_display_cart.php on line 49 line 49 is GetSQLValueString($_SESSION['contact_first_name'], "text"), Link to comment https://forums.phpfreaks.com/topic/45576-solved-help-needed-with-insert/#findComment-221319 Share on other sites More sharing options...
kenrbnsn Posted April 4, 2007 Share Posted April 4, 2007 That means the function "GetSQLValueString" is not defined anywhere. It is not a standard PHP function. Where did you get this code? Ken Link to comment https://forums.phpfreaks.com/topic/45576-solved-help-needed-with-insert/#findComment-221327 Share on other sites More sharing options...
jim.davidson Posted April 4, 2007 Author Share Posted April 4, 2007 It came from dreamweaver, but I'll gladly change it if you know another way Link to comment https://forums.phpfreaks.com/topic/45576-solved-help-needed-with-insert/#findComment-221329 Share on other sites More sharing options...
Barand Posted April 4, 2007 Share Posted April 4, 2007 11 fields but only 10 "%s" in the VALUES() bit Link to comment https://forums.phpfreaks.com/topic/45576-solved-help-needed-with-insert/#findComment-221449 Share on other sites More sharing options...
jim.davidson Posted April 5, 2007 Author Share Posted April 5, 2007 Thanks for the help Link to comment https://forums.phpfreaks.com/topic/45576-solved-help-needed-with-insert/#findComment-222131 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.