156418 Posted October 9, 2006 Share Posted October 9, 2006 I have the following code which is supposed to be taking values which have been posted, the values are posting ok as I can get them to Echo ok, but not put the values into the DB.I'm connecting to the DB ok[code]<?php// make the variables easy to access in our queries$_POST['cartId'] = $cartId;$_POST['AdultQuantity'] = $AdultQuantity;$_POST['Adult'] = $ATicketType;$_POST['AdultPrice'] = $ATicketPrice;$_POST['ChildQuantity'] = $ChildQuantity;$_POST['Child'] = $CTicketType;$_POST['ChildPrice'] = $CTicketPrice;$_POST['PresentQuantity'] = $PresentQuantity;$_POST['Present'] = $PTicketType;$_POST['PresentPrice'] = $PTicketPrice;//1) Add Adult Details to the CalcAdult Table $query = "INSERT INTO CalcAdult ( cartId, AdultQuantity, Adult, AdultPrice) VALUES ( '$cartId', '$AdultQuantity', '$ATicketType', '$ATicketPrice')"; $insert = mysql_query($query) or (mysql_error());?> <?php//2) Add Child Details to the CalcChild Table $query2 = "INSERT INTO CalcChild ( cartId, ChildQuantity, Child, ChildPrice) VALUES ( '$cartId', '$ChildQuantity', '$CTicketType', '$CTicketPrice')"; $insert = mysql_query($query2) or (mysql_error());?> <?php//3) Add Present Details to the CalcPresent Table $query3 = "INSERT INTO CalcPresent ( cartId, PresentQuantity, Present, PresentPrice) VALUES ( '$cartId', '$PresentQuantity', '$PTicketType', '$PTicketPrice')"; $insert = mysql_query($query3) or (mysql_error());?> [/code]Thanks for any help Quote Link to comment Share on other sites More sharing options...
baiju Posted October 9, 2006 Share Posted October 9, 2006 you assigning data in opp direction$_POST['cartId'] = $cartId;$_POST['AdultQuantity'] = $AdultQuantity;it should be$cartId = $_POST['cartId'] ;$AdultQuantity=$_POST['AdultQuantity'] ; Quote Link to comment Share on other sites More sharing options...
156418 Posted October 9, 2006 Author Share Posted October 9, 2006 I've tried both ways with no luck, either way results with an empty table ???[code]<?php// make the variables easy to access in our queries$cartId = $_POST['cartId'];$AdultQuantity = $_POST['AdultQuantity'];$ATicketType = $_POST['Adult'];$ATicketPrice = $_POST['AdultPrice'];$ChildQuantity = $_POST['ChildQuantity'];$CTicketType = $_POST['Child'];$CTicketPrice = $_POST['ChildPrice'];$PresentQuantity = $_POST['PresentQuantity'];$PTicketType = $_POST['Present'];$PTicketPrice = $_POST['PresentPrice'];//1) Add Adult Details to the CalcAdult Table $query = "INSERT INTO CalcAdult ( cartId, AdultQuantity, Adult, AdultPrice) VALUES ( '$cartId', '$AdultQuantity', '$ATicketType', '$ATicketPrice')"; $insert = mysql_query($query) or (mysql_error());?> <?php//2) Add Child Details to the CalcChild Table $query2 = "INSERT INTO CalcChild ( cartId, ChildQuantity, Child, ChildPrice) VALUES ( '$cartId', '$ChildQuantity', '$CTicketType', '$CTicketPrice')"; $insert = mysql_query($query2) or (mysql_error());?> <?php//3) Add Present Details to the CalcPresent Table $query3 = "INSERT INTO CalcPresent ( cartId, PresentQuantity, Present, PresentPrice) VALUES ( '$cartId', '$PresentQuantity', '$PTicketType', '$PTicketPrice')"; $insert = mysql_query($query3) or (mysql_error());?> [/code] Quote Link to comment Share on other sites More sharing options...
AndyB Posted October 9, 2006 Share Posted October 9, 2006 Time for a little bit of debug/echo assistance.Change each query so you can see what's happening. So change this (example):[code]$insert = mysql_query($query) or (mysql_error());[/code]to this (example):[code]echo $query. "<br/>";$insert = mysql_query($query) or die("Error ". mysql_error(). " with query ". $query);[/code] Quote Link to comment Share on other sites More sharing options...
baiju Posted October 9, 2006 Share Posted October 9, 2006 then show your db coonection file Quote Link to comment Share on other sites More sharing options...
156418 Posted October 9, 2006 Author Share Posted October 9, 2006 The Echo assisted in this one.It was grumbling about some of the names of the values being passed, I've set them all exact now (in the form compared with the DB) and its worked okThanks for the help Quote Link to comment 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.