jakebur01 Posted May 25, 2007 Share Posted May 25, 2007 ok, I have inserted all the customers info into all the necessary tables on the previous page. Also, on the previous page the customer enters in their credit card info.. Now on this page I am trying to update the credit card info into the orders table. I am having trouble getting the data to go in. <?php include ('book_sc_fns.php'); // The shopping cart needs sessions, so start one session_start(); do_html_header('Checkout'); $c_phone = $_POST['c_phone']; $c_email = $_POST['c_email']; $card_type = $_POST['card_type']; $card_number = $_POST['card_number']; $card_month = $_POST['card_month']; $card_year = $_POST['card_year']; $card_name = $_POST['card_name']; $name = $_SESSION['customer_name']; $address = $_SESSION['customer_address']; if($_SESSION['cart']&&$c_phone&&$c_email&&$card_type&&$card_number&& $card_month&&$card_year&&$card_name ) { //display cart, not allowing changes and without pictures display_cart($_SESSION['cart'], false, 0); display_shipping(calculate_shipping_cost()); if(process_card($_POST)) { //empty shopping cart session_destroy(); echo 'Thankyou for shopping with us. Your order has been placed.'; display_button('index.php', 'continue-shopping', 'Continue Shopping'); } else { echo 'Could not process your card. '; echo 'Please contact the card issuer or try again.'; display_button('purchase.php', 'back', 'Back'); } } else { echo 'You did not fill in all the fields, please try again.<hr />'; display_button('purchase.php', 'back', 'Back'); } do_html_footer(); ?> And here is the process_card() function. <?php function process_card($card_details) { extract($card_details); $conn = db_connect(); // insert customer address $query = "UPDATE 'orders' SET 'c_phone' = '$c_phone', 'c_email' = '$c_email', 'card_type' = '$card_type', 'card_number' = '$card_number', 'card_month' = '$card_month', 'card_year' = '$card_year', 'card_name' = '$card_name' WHERE 'orders' . 'ship_name' = '$name'"; $result = $conn->query($query); return true; } I still have a lot to learn, but I am starting to see things a little more clearly. `Jake Quote Link to comment https://forums.phpfreaks.com/topic/52922-solved-trouble-updating-data-into-table/ Share on other sites More sharing options...
jitesh Posted May 25, 2007 Share Posted May 25, 2007 Column name and table name must not have quate (') Keep ` insted of ' $query = "UPDATE 'orders' SET `c_phone` = '$c_phone', `c_email`= '$c_email', `card_type` = '$card_type', `card_number` = '$card_number', `card_month` = '$card_month', `card_year` = '$card_year', `card_name` = '$card_name' WHERE `orders` . `ship_name` = '$name'"; Quote Link to comment https://forums.phpfreaks.com/topic/52922-solved-trouble-updating-data-into-table/#findComment-261353 Share on other sites More sharing options...
jakebur01 Posted May 25, 2007 Author Share Posted May 25, 2007 I changed it to this: <?php function process_card($card_details) { extract($card_details); $conn = db_connect(); // insert customer address $query = "UPDATE `orders` SET `c_phone` = '$c_phone', `c_email` = '$c_email', `card_type` = '$card_type', `card_number` = '$card_number', `card_month` = '$card_month', `card_year` = '$card_year', `card_name` = '$card_name' WHERE `orders` . `ship_name` = '$name'"; /// where // name = '$name' and address = '$address' // and city = '$city' and state = '$state' // and zip = '$zip' and country = '$country'"; $result = $conn->query($query); return true; } still no dice... I don't know what the deal is.. Quote Link to comment https://forums.phpfreaks.com/topic/52922-solved-trouble-updating-data-into-table/#findComment-261357 Share on other sites More sharing options...
jitesh Posted May 25, 2007 Share Posted May 25, 2007 What are trying to do here WHERE `orders` . `ship_name`(???) = '$name'"; Quote Link to comment https://forums.phpfreaks.com/topic/52922-solved-trouble-updating-data-into-table/#findComment-261359 Share on other sites More sharing options...
jakebur01 Posted May 25, 2007 Author Share Posted May 25, 2007 orderid customerid amount date order_status ship_name ship_address ship_city ship_state ship_zip ship_country c_phone c_email card_type card_number card_month card_year card_name Edit Delete 8 13 5.27 2007-05-25 PARTIAL test test test test test test 0 0 0 0 0 0 0 I am trying to tell it what row I want it to update to. ship_name is the name of a column where the customers name is stored, I was trying to get it to store the data where the customers name that is stored in the session matches the name in that column. Quote Link to comment https://forums.phpfreaks.com/topic/52922-solved-trouble-updating-data-into-table/#findComment-261362 Share on other sites More sharing options...
jitesh Posted May 25, 2007 Share Posted May 25, 2007 Try this WHERE orders.ship_name = '$name'"; This would be like this WHERE `orders.ship_name` = '$name'"; Quote Link to comment https://forums.phpfreaks.com/topic/52922-solved-trouble-updating-data-into-table/#findComment-261364 Share on other sites More sharing options...
jakebur01 Posted May 25, 2007 Author Share Posted May 25, 2007 Does this part of my code look ok? if($_SESSION['cart']&&$c_phone&&$c_email&&$card_type&&$card_number&& $card_month&&$card_year&&$card_name ) { //display cart, not allowing changes and without pictures display_cart($_SESSION['cart'], false, 0); display_shipping(calculate_shipping_cost()); if(process_card($_POST)) { //empty shopping cart session_destroy(); echo 'Thankyou for shopping with us. Your order has been placed.'; display_button('index.php', 'continue-shopping', 'Continue Shopping'); } Quote Link to comment https://forums.phpfreaks.com/topic/52922-solved-trouble-updating-data-into-table/#findComment-261366 Share on other sites More sharing options...
jitesh Posted May 25, 2007 Share Posted May 25, 2007 if(isset($_SESSION['cart']) && isset($c_phone) && isset($c_email) && isset($card_type) && isset($card_number) && isset($card_month) && isset($card_year) && isset($card_name)) { ......... .......... Quote Link to comment https://forums.phpfreaks.com/topic/52922-solved-trouble-updating-data-into-table/#findComment-261367 Share on other sites More sharing options...
jakebur01 Posted May 25, 2007 Author Share Posted May 25, 2007 The data is inserting perfect on the previous page but is still not updating the credit card info. I appreciate you taking the time to help me though jitesh. Quote Link to comment https://forums.phpfreaks.com/topic/52922-solved-trouble-updating-data-into-table/#findComment-261373 Share on other sites More sharing options...
jitesh Posted May 25, 2007 Share Posted May 25, 2007 echo your update query then test in mysql. Quote Link to comment https://forums.phpfreaks.com/topic/52922-solved-trouble-updating-data-into-table/#findComment-261374 Share on other sites More sharing options...
jakebur01 Posted May 25, 2007 Author Share Posted May 25, 2007 MySQL said: Documentation #1054 - Unknown column 'orders.ship_name' in 'where clause' Also, I wasn't retrieving my session on this page: function process_card($card_details) { $name = $_SESSION['customer_name']; Quote Link to comment https://forums.phpfreaks.com/topic/52922-solved-trouble-updating-data-into-table/#findComment-261380 Share on other sites More sharing options...
jakebur01 Posted May 25, 2007 Author Share Posted May 25, 2007 this got it in mysql: WHERE `orders` . `ship_name` = 'kirby'; Quote Link to comment https://forums.phpfreaks.com/topic/52922-solved-trouble-updating-data-into-table/#findComment-261381 Share on other sites More sharing options...
jakebur01 Posted May 25, 2007 Author Share Posted May 25, 2007 Man!!! it works now!! Thank you for helping me... I really appreciate it! `Jake Quote Link to comment https://forums.phpfreaks.com/topic/52922-solved-trouble-updating-data-into-table/#findComment-261383 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.