Jump to content

156418

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Everything posted by 156418

  1. Never mind, solved it by GROUP BY now. Many thanks for all the help, this was a system I've taken over the administration of, at least after this event i'll have the time to scrap this Database and start with a new one taking out all the multiple tables which have made it confusing!
  2. Thanks for the help, I've got it working as I want, just have one problem. I had to change the query slightly as the date is in the database as text rather than in Date Format. However the problem is that each record which is returned is displayed 3 times [code]<?php require('db_connect.php'); ?> <?php $query = "select Callbacks.* from Callbacks,TicketsSold where Callbacks.cartId = TicketsSold.OrderID and MC_EventDate in ('Saturday 9th December')"; $results = mysql_query($query) or die(mysql_error()); ?> </head> <body> <p>Attendance List: Saturday 9th December 2006</p> <p> <?php while ($row = mysql_fetch_array($results)) {   extract($row);   echo "Callback Number: $CallbackNo <br>";   echo "Customer Name: $customername <br>";   echo "Customer Address: $customeraddress <br>";   echo "Ticket Details: $M_disc <br>"; } ?>[/code] Any ideas as to what I've done wrong?
  3. Hi, I think there's probably an easy way to do this, but its got me a little confused. I would like to Run a query, which selects two tables, Callbacks and TicketsSold. Then I'd like to display the contents of Callbacks, where the cartID = cartID in TicketsSold, and where MC_EventDate equals either: Saturday 9th December Sunday 10th December Saturday 16th December Sunday 17th December Saturday 23rd December. I will have 5 seperate pages, so I can hard code the date into the query, but am struggling on how to put the query togther to get the necessary results. Do I need to run seperate queries on the tables then merge them somehow? I have PHP version  4.4.2 and MySQL version 4.1.21-standard if that makes a difference Many thanks for any pointers.
  4. Hmmm thanks, thats annoying, as thats something that Worldpay spit out as one of their defined colums. Sorted it now by sending them an additional field which is put into DB. Everything working ok. Thanks for all the help
  5. Thanks, I've removed that but still got the same error  ???
  6. I'm trying to run the following query: [code]<?php // sort out the input $cartId = $_POST['cartId']; $description = $_POST['desc']; $totalamount = $_POST['amount']; $transactioncurrency = $_POST['currency']; $customername = $_POST['name']; $customeraddress = $_POST['address']; $postcode = $_POST['postcode']; $country = $_POST['country']; $tel = $_POST['tel']; $email = $_POST['email']; $transId = $_POST['transId']; $transStatus = $_POST['transStatus']; $transTime = $_POST['transTime']; $authAmount = $_POST['authAmount']; $authCurrency = $_POST['authCurrency']; $rawAuthMessage = $_POST['rawAuthMessage']; $rawAuthCode = $_POST['rawAuthCode']; $cardType = $_POST['cardType']; $AVS = $_POST['AVS']; //1) Now dump the lot into the DB   $query = "INSERT INTO Callbacks (             cartId, desc, amount, currency, name, address, postcode, country, tel, email, transId, transStatus, transTime, authAmount, authCurrency, rawAuthMessage, rawAuthCode, cardType, AVS)             VALUES (             '$cartId',             '$description',             '$totalamount',             '$transactioncurrency',             '$customername',             '$customeraddress',             '$postcode',             '$country',             '$countryString',             '$tel',             '$email',             '$transId', '$transStatus', '$transTime', '$authAmount', '$authCurrency', '$rawAuthMessage', '$rawAuthCode', '$cardType',             '$AVS')"; echo $query. "<br/>"; $insert = mysql_query($query) or die("Error ". mysql_error(). " with query ". $query); ?> [/code] When the query runs, the echo is showing that all the data is there to be put in, but I'm getting the error. [quote]Error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc, amount, currency, name, address, postcode, country, countryString, tel, em' at line 2 with query INSERT INTO Callbacks etc[/quote] Knowing my typing, its probably a typo somewhere, but I can't spot it! Any help greatly received
  7. Thanks Barand your a genius! that works excellently, also thanks to craygo for your input
  8. Thanks Barand, that looks nice and simple, but I'm getting an error "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE EventID = '21'' at line 2" This is my query: All of the fields are correct: [code]<?php $event = mysql_real_escape_string(trim(stripslashes($_POST['event']))); $query = "SELECT EventID, TicketType, SUM(Qty) as total FROM TicketsSold GROUP BY EventID, TicketType  WHERE EventID = '$event'"; $results = mysql_query($query) or die(mysql_error()); ?>[/code]
  9. I have a table in my database called TicketsSold. in that I have thefFields: Refrence, OrderID, EventID, TicketType and Qty I can put together a query no problem which can list the tickets sold for a certain event. i.e [code]<?php $event = mysql_real_escape_string(trim(stripslashes($_POST['event']))); $query = "SELECT * FROM TicketsSold WHERE EventID = '$event'"; $results = mysql_query($query) or die(mysql_error()); ?>[/code] But, is there a way that I can instead of listing eveything, total up everything into groups. For example have it list by EventID then total the amount sold in each ticket type, Adult, Child, Senior, Family and Present. Many thanks for any help. (if this would be better in the MySQL Forum then sorry, as I was unaware what it would come under)
  10. Thanks, I can see the logic that it would implement, but (forgive the ignorance!) where do I place that code, as whereever it goes on my page, or next page it ignores it - I have changed the name to match that of the input with no sucess. I should also have said that if they enter anything other than a number in the box it should redirect them to an error page.
  11. I have a basic table/form which is passing the various inputs onto the next stage, what I want to do is where the Quantity box is only allow the use to enter a number, and reject on blank or anything else. Could someone show an easy way to do that, all the validation scripts I've found seem rather complicated or prevent the input being sent in the headers. Many thanks [code]<table width="70%" border="0">   <tr>     <td width="13%" bgcolor="#E6D0DD">Quantity</td>     <td width="74%" bgcolor="#E6D0DD">Ticket Type </td>     <td width="13%" bgcolor="#E6D0DD">Price</td>   </tr>   <tr>     <td bgcolor="#E6D0D2"><div align="center">       <input name="AdultQuantity" type="text" value="0" size="5">     </div></td>     <td bgcolor="#E6D0D2">Adult     <input type="hidden" name="ATicketType" value="Adult" size="13" maxlength="20"></td>     <td bgcolor="#E6D0D2">&pound;9       <input type="hidden" name="APrice" value="9" size="10" maxlength="1"> </td>   </tr>   <tr>     <td bgcolor="#E6D0D2"><div align="center">       <input name="ChildQuantity" type="text" value="0" size="5">     </div></td>     <td bgcolor="#E6D0D2">Child       <input type="hidden" name="CTicketType" value="Child" size="13" maxlength="20"> </td>     <td bgcolor="#E6D0D2">&pound;6       <input type="hidden" name="CPrice" value="6" size="10" maxlength="1"> </td>   </tr>   <tr>     <td bgcolor="#E6D0D2"><div align="center">       <input name="PresentQuantity" type="text" value="0" size="5">     </div></td>     <td bgcolor="#E6D0D2">Present       <input type="hidden" name="PTicketType" value="Present" size="13" maxlength="20"> </td>     <td bgcolor="#E6D0D2">&pound;3       <input type="hidden" name="PPrice" value="3" size="10" maxlength="1"></p> </td>   </tr> </table> [/code]
  12. Hi, its similar to a shopping cart but not quite! It takes a Quantity and simply posts it to the next page, also there's some hidden text boxes which post the amount for each item (I know thats cheating, but I cant find any other way easily! This is the page prior to that one, which posts the Quantity and price through [code]<form method="POST" action="Stage6-Final.php"> <table width="70%" border="0">   <tr>     <td width="13%" bgcolor="#E6D0DD">Quantity</td>     <td width="74%" bgcolor="#E6D0DD">Ticket Type </td>     <td width="13%" bgcolor="#E6D0DD">Price</td>   </tr>   <tr>     <td bgcolor="#E6D0D2"><div align="center">       <input name="AdultQuantity" type="text" value="0" size="5">     </div></td>     <td bgcolor="#E6D0D2">Adult     <input type="hidden" name="ATicketType" value="Adult" size="13" maxlength="20"></td>     <td bgcolor="#E6D0D2">&pound;9       <input type="hidden" name="APrice" value="9" size="10" maxlength="1"> </td>   </tr>   <tr>     <td bgcolor="#E6D0D2"><div align="center">       <input name="ChildQuantity" type="text" value="0" size="5">     </div></td>     <td bgcolor="#E6D0D2">Child       <input type="hidden" name="CTicketType" value="Child" size="13" maxlength="20"> </td>     <td bgcolor="#E6D0D2">&pound;6       <input type="hidden" name="CPrice" value="6" size="10" maxlength="1"> </td>   </tr>   <tr>     <td bgcolor="#E6D0D2"><div align="center">       <input name="PresentQuantity" type="text" value="0" size="5">     </div></td>     <td bgcolor="#E6D0D2">Present       <input type="hidden" name="PTicketType" value="Present" size="13" maxlength="20"> </td>     <td bgcolor="#E6D0D2">&pound;3       <input type="hidden" name="PPrice" value="3" size="10" maxlength="1"></p> </td>   </tr> </table> </form>[/code] It also posts some other stuff, user details etc which is being pulled from the Database. On the page that recieves it, I have the following: [code]Tickets: </div>            </td>             <td width="79%"><span class="style11"><?php echo $_POST['AdultQuantity']; ?> X <?php echo $_POST['ATicketType']; ?> @ £<?php echo $_POST['APrice']; ?> Each  <input type="input" name="AT" value="<?php echo $_POST['AdultQuantity'] * $_POST['APrice']; ?>" size="13" maxlength="20"><br>   <?php echo $_POST['ChildQuantity']; ?> X <?php echo $_POST['CTicketType']; ?> @ £<?php echo $_POST['CPrice']; ?> Each<input type="input" name="CT" value="<?php echo $_POST['ChildQuantity'] * $_POST['CPrice']; ?>" size="13" maxlength="20"><br>   <?php echo $_POST['PresentQuantity']; ?> X <?php echo $_POST['PTicketType']; ?> @ £<?php echo $_POST['PPrice']; ?> Each<input type="input" name="PT" value="<?php echo $_POST['PresentQuantity'] * $_POST['PPrice']; ?>" size="13" maxlength="20"><br></span></td>           </tr>           <tr>             <td width="21%">               <div align="right" class="style11 style12 style14">Total to Pay:  </div>            </td>             <td width="79%"><span class="style11 style12 style14"><?php echo $_POST['AT'] * $_POST['PT']; ?></span></td>           </tr>[/code] Thats a cut down of it, the rest is just posting the rest of what was sent from the page before. There's a lot of multiple posting of the same variables here as well. No doubt there's a quicker way to do it all, adding and pulling back out from a DB, but I dunno where to begin on making that!
  13. Ah, I see. Would I be right in assuming that I wont be able to add the three totals together without first posting the results?
  14. Thanks, It looks simple enough, but how do i get it to display the output rather than the command [code]<?php echo $_POST['$AdultQuantity * $APrice']; ?>[/code]
  15. I have the following code, which is posted through from a form on a previous page: [code]<?php echo $_POST['AdultQuantity']; ?> X <?php echo $_POST['ATicketType']; ?> @ £<?php echo $_POST['APrice']; ?> Each<br> <?php echo $_POST['ChildQuantity']; ?> X <?php echo $_POST['CTicketType']; ?> @ £<?php echo $_POST['CPrice']; ?> Each<br> <?php echo $_POST['PresentQuantity']; ?> X <?php echo $_POST['PTicketType']; ?> @ £<?php echo $_POST['PPrice']; ?>[/code] what I'd like to do is multiple the Quantity by the Price for each of the three, and then total all three together in another part on the page Is that possible, or will I need to add it into the Database and pull the figures back out?
  16. Thats Brilliant, thank you. I'll have a look into the prevention methods as well
  17. I have the following script, which updates a database table with the values posted though, is there an easy I can add to that so that if the cartId is already in the CalcAdult table it updates the record for it, rather than add another one, the structure of the table is the 4 fields as below, plus a CalcID primary key which auto_incerements [code]<?php $cartId = $_POST['cartId']; $AdultQuantity = $_POST['AdultQuantity']; $ATicketType = $_POST['ATicketType']; $APrice = $_POST['APrice']; $ChildQuantity = $_POST['ChildQuantity']; $CTicketType = $_POST['CTicketType']; $CTicketPrice = $_POST['CPrice']; $PresentQuantity = $_POST['PresentQuantity']; $PTicketType = $_POST['PTicketType']; $PTicketPrice = $_POST['PPrice']; //1) Add Adult Details to the CalcAdult Table   $query = "INSERT INTO CalcAdult (             cartId, AdultQuantity, ATicketType, APrice)             VALUES (             '$cartId',             '$AdultQuantity',             '$ATicketType',             '$APrice')"; $insert = mysql_query($query)     or (mysql_error()); ?> [/code] Many thanks
  18. 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 ok Thanks for the help
  19. 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]
  20. 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
  21. Brilliant thank you. I had just noticed in my original code I was thinking MsSQL rather than MySQL
  22. I've cut my query down now so that its only doing 1 thing, but still cant seem to find where the error is coming from. I'm getting [quote]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1[/quote] For the following: [code]<?php //we need to connect to the database so require('db/db_connect.php'); ?> <?php $query = "SELECT Max(CustID) AS CustID2 FROM CustomerDetails Where EmailAddress = '"& EmailAddress &"'"; $results = mysql_query($query) or die(mysql_error()); ?><?php // Show only Name, Price and Image while ($row = mysql_fetch_array($results)) {   extract($row);   echo $CustID2; } ?>[/code] The only part I cant work out of the syntax is correct is the part with EmailAddress, thats being posted in from a previous form, I know thats being posted ok, but cannot find if the code for the Query is correct.
  23. So I've got the first one working with Event Description But the next one is event date, there are 5 items listed, and the drop down populates ok, however it doesn't pass it on in the POST. I.e the EventDescription, Password and EmailAddress are passing on find, but EventDate which is being seleted at this point isnt. [code] <?php //we need to connect to the database so require ( 'db/db_connect.php' ); $result = mysql_query ( 'SELECT * FROM AvailableDates WHERE EventID = 22;' ) or die ( 'Query Error: ' . mysql_error () ); if ( mysql_num_rows ( $result ) > 0 ) { echo "<select name='AvailableDates'>"; while ( $row = mysql_fetch_array ( $result, MYSQL_ASSOC ) ) { echo "<option value='" . $row['EventDate'] . "'>" . $row['EventDate'] . "</a>"; } echo '</select>'; } else { echo 'can not create select box, no results found'; } ?>       <input type="hidden" name="EmailAddress" value="<?php echo $_POST['EmailAddress']; ?>">         <input type="hidden" name="Password" value="<?php echo $_POST['Password']; ?>">   <input type="hidden" name="EventDescription" value="<?php echo $_POST['EventDescription']; ?>">       <input type="submit" name="Submit" value="Submit"></form>[/code]
  24. In my sctipt, I'm taking some values which have been posted through from a form, and then adding them to the Database. This part is working ok, and the values are being written, however I'm trying now to take the MAX Value of CustID and carry it though as CustID2 later on, once the use makes the selection from the EventDescription box (the drop down is working fine) However my CustID2 and Password fields are blank. (i've made them as input boxes rather than hidden to check that they are working. Event Description is the only value being posted. [code]<?php //we need to connect to the database so require('db/db_connect.php'); // make the variables easy to access in our queries $Title = $_POST["Title"]; $Initials = $_POST['Initials']; $Surname = $_POST['Surname']; $HouseNo = $_POST['HouseNo']; $Road_Name = $_POST['Road_Name']; $Town = $_POST['Town']; $County = $_POST['County']; $Postcode = $_POST['Postcode']; $Country = $_POST['Country']; $TelHome = $_POST['TelHome']; $EmailAddress = $_POST['EmailAddress']; $Password = $_POST['Password']; //1) Assign Customer Number to new Customer, or find existing customer number   $query = "INSERT INTO CustomerDetails (             Title, Initials, Surname, HouseNo, RoadName, Town, County, Postcode, Country, TelHome, EmailAddress, Password)             VALUES (             '$Title',             '$Initials',             '$Surname',             '$HouseNo',             '$Road_Name',             '$Town',             '$County',             '$Postcode',             '$Country',             '$TelHome',             '$EmailAddress',             '$Password')";   $insert = mysql_query($query)     or (mysql_error()); ?> <?php $query = "SELECT Max(CustID) AS CustID2 FROM CustomerDetails Where EmailAddress = '"& EmailAddress &"'" $results = mysql_query($query) or die(mysql_error()); ?> <form name="form1" method="post" action="Stage4-Date.php">               <?php //we need to connect to the database so require ( 'db/db_connect.php' ); $result = mysql_query ( 'SELECT * FROM Events WHERE EventID = 22;' ) or die ( 'Query Error: ' . mysql_error () ); if ( mysql_num_rows ( $result ) > 0 ) { echo "<select name='EventDescription'>"; while ( $row = mysql_fetch_array ( $result, MYSQL_ASSOC ) ) { echo "<option value='" . $row['EventDescription'] . "'>" . $row['EventDescription'] . "</a>"; } echo '</select>'; } else { echo 'can not create select box, no results found'; } ?>       <input type="input" name="CustID" value="<?php echo $_POST['CustID2']; ?>">         <input type="input" name="Password" value="<?php echo $_POST['Password']; ?>">   <input type="submit" name="Submit" value="Submit"></form>[/code] I've chopped out the HTML in the middle of the two php tags as it isnt necessary for the script, but can someone point out where the MAX query is failing and not displaying the data. I'm not getting any error messages. Thanks for any help
  25. Many thanks, I hadn't come across the error as my first page I'm using that on only has one option in the table, but the next one will need multiple options
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.