mindapolis Posted May 3, 2012 Share Posted May 3, 2012 hi, I have a webpage that is driven by a database mostly. it has a catalog of dog treats and most will transfer to the checkout page but 2 two won't. I have checked the database and everything looks fine if it would help, here 's the webpage. http://auntievics.com/treats.php. it's the Cara The Flirt's K9 Canoli Stuffed and the Cara The Flirt's K9 Canoli Unstuffed that won't transfer. Any help would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/262025-data-not-transferring/ Share on other sites More sharing options...
MMDE Posted May 3, 2012 Share Posted May 3, 2012 We need to see some code... Please use the code tag when you post the code! Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/262025-data-not-transferring/#findComment-1342745 Share on other sites More sharing options...
mindapolis Posted May 3, 2012 Author Share Posted May 3, 2012 <?php session_start(); if(!isset($_SESSION['quantity'])) { $_SESSION['quantity']=array(); //if there are no quantities selected, the array is empty if(is_array($_POST['quantity']))//if there are items in the cart { echo $quantity; header("location: checkOut.php"); } } require_once("functions.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Auntie Vic's products </title> <meta name="keywords" content="Dog treats, organic dog treats, dog food, dog allergies, Indiana" /> <meta name="description" content="Check out the many dog treats that can be ordered for dogs who may or may not have allergies! " /> <style type="text/css"> td { padding-bottom:20px; } #productCatalog { width:410px; margin-right: auto; margin-left: auto; } #disclaimer { background-color: #666633; padding:10px; } </style> <link href="doggyTreats.css" rel="stylesheet" type="text/css" /> </head> <body> <?php logo(); navBar(); echo "<div id=\"productCatalog\">"; echo "<form action=\"checkOut.php\" method=\"post\" name=\"catalog\">"; DatabaseConnection(); $query = "SELECT * FROM treats WHERE productType = 'regular'"; $result_set = mysql_query($query) or die(mysql_error()); $i = 0; echo "<table>"; while ($row = mysql_fetch_array($result_set)) { echo '<tr><td width="200px"><img src="'.$row['product_pic'].'" /></td><td width="200px"><b>'.$row['product_title'].'</b><br />'.$row['product_Description'].'<br /> Price: $'.$row['price'].$row['pricePer'].'<br /><br />Quantity <input name="quantity'.$row["product_id"].'" type="text" size="2" /></td></tr>'; } echo "<tr>"; echo "<td colspan = '2'> SPECIALITY TREATS </td>"; $query = "SELECT * FROM treats WHERE productType = 'specialty'"; $result_set = mysql_query($query) or die(mysql_error()); $i = 0; while ($row = mysql_fetch_array($result_set)) { echo '<tr><td width="200px"><img src="'.$row['product_pic'].'" /></td><td width="200px"><b>'.$row['product_title'].'</b><br />'.$row['product_Description'].'<br /> Price: $'.$row['price'].$row['pricePer'].'<br /><br />Quantity <input name="quantity'.$row["product_id"].'" type="text" size="2" /></td></tr>'; } //end of catalog echo "<tr>"; echo "<td id = 'disclaimer' colspan = '2'> Auntie Vic carefully researches all recipes on this site. All of them are taste tested and tried by various dogs. However, there is always a possibility some dogs will have a food intolerance and we cannot be held liable in this case. These treats are treats meant for special occasions, celebrations and the simple enjoyment of giving your dog a little extra something. They should not be used to replace a properly balanced meal. Always ask your vet for advice before adding homemade treats to any diet. </td>"; echo "</tr>"; echo "<tr>"; echo "<td><input name=\"ProceedToCheckout\" type=\"submit\" value=\"Proceed to Checkout\" /></td>"; echo "</tr>"; echo "</table>"; echo "</form>"; echo "</div>"; footer(); ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/262025-data-not-transferring/#findComment-1342748 Share on other sites More sharing options...
Mahngiel Posted May 3, 2012 Share Posted May 3, 2012 Although several other products have apostrophes in their names, no other products had apostrophes in their form names than the two you're having issues with. Quote Link to comment https://forums.phpfreaks.com/topic/262025-data-not-transferring/#findComment-1342763 Share on other sites More sharing options...
PFMaBiSmAd Posted May 3, 2012 Share Posted May 3, 2012 As someone suggested in a previous thread, your product_id should be the auto-increment identifier from your database table, not a text string. Quote Link to comment https://forums.phpfreaks.com/topic/262025-data-not-transferring/#findComment-1342804 Share on other sites More sharing options...
mindapolis Posted May 4, 2012 Author Share Posted May 4, 2012 okay, I deleted that field, added a product_id field, tried to make that the primaries key with auto incredimnt and its saying SQL query: ALTER TABLE `treats` CHANGE `product_id` `product_id` INT( 3 ) NOT NULL AUTO_INCREMENT MySQL said: Documentation #1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key in this table there should not be any other auto increment fields. Quote Link to comment https://forums.phpfreaks.com/topic/262025-data-not-transferring/#findComment-1342888 Share on other sites More sharing options...
PFMaBiSmAd Posted May 4, 2012 Share Posted May 4, 2012 It would appear that your table already has an auto-increment column. All you would need to do is use that existing column as the id. Quote Link to comment https://forums.phpfreaks.com/topic/262025-data-not-transferring/#findComment-1342995 Share on other sites More sharing options...
mindapolis Posted May 6, 2012 Author Share Posted May 6, 2012 ok, I changed the product_id to auto increment but it still won't transfer the information from one page to another Quote Link to comment https://forums.phpfreaks.com/topic/262025-data-not-transferring/#findComment-1343423 Share on other sites More sharing options...
Mahngiel Posted May 6, 2012 Share Posted May 6, 2012 Now it's totally wrong! All of your inputs are named 'quantity0' and any value you add to one of the inputs gets crossed with all of them. Entering 4 into any of the fields creates a rather surprising total! Quote Link to comment https://forums.phpfreaks.com/topic/262025-data-not-transferring/#findComment-1343427 Share on other sites More sharing options...
mindapolis Posted May 6, 2012 Author Share Posted May 6, 2012 I did what you guys said to do so how do I fix it? Quote Link to comment https://forums.phpfreaks.com/topic/262025-data-not-transferring/#findComment-1343480 Share on other sites More sharing options...
Mahngiel Posted May 6, 2012 Share Posted May 6, 2012 I have no idea what your DB Table looks like, nor your server side code, but this is how I do things: Small example table and getting to the meat. +-------------+---------------+-----------------+------------------+ | product_id | product_name | product_desc | product_cost_ per | +-------------+---------------+-----------------+------------------+ | 1 | Bo's Chunky... | Whole whea... | $10.00 / lb | | 2 | Miss Cuddles... | Unbleached ... | $10.00 / lb | <?php // Retrieve the data $products = (your querying method); // Ensure successful query if( $products): ?> // Since our query was successful, we can open our form <form method="POST" action="la-la-land.php" /> Now, you write one code block which iterates through all of your products. <?php foreach ( $products as $product ): ?> <section class="dog_treats" data-treat=" <?php echo $product->product_id; ?> "> <h3><?php echo $product->product_title; ?></h3> <div> <?php echo $product->product_desc; ?> <br /> <?php echo $product->product_cost_per; ?> <br /> <input type="text" name="treats[ <?php echo $product->product_id; ?> ]" /> </div> </section> <?php endforeach; ?> I would accept the input as an array so it makes it easier to deal with them on the opposing end. After each treat section has been crafted, close out the form <input type="submit" name="submit" value="buy my stuff" /> </form> <?php endif?> The receiving script: <?php if( isset($_POST['submit'] ) { foreach( $_POST['treats'] as $treat ) { // Process handling here } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/262025-data-not-transferring/#findComment-1343504 Share on other sites More sharing options...
PFMaBiSmAd Posted May 6, 2012 Share Posted May 6, 2012 I did what you guys said to do so how do I fix it? Thinking about the meaning of what you are doing is required in programming, because computers only do exactly what their code and data tells them. I'm not trying to pick on you or be mean, but you must think about what goal you are trying to achieve and how it relates to your code and data. A statement that - "your product_id should be the auto-increment identifier from your database table, not a text string." is a suggested direction that requires more than one step to accomplish (all programming involves breaking down a problem into the individual steps needed to accomplish any task.) 1a) If you didn't already have an auto-increment column, you would need to add one to your table. Are you sure you didn't already have an auto-increment column with values in it? Most database management tools will automatically make the first column you create an auto-increment index. 2a) If you had to added an auto-increment column, you will now need to assign numerical id values (1,2,3,...) to your existing products and setup the table so that it will use the next available auto-increment value when you insert new rows (the database might do this for you after you assign values to the column.) Given that you have a relatively small number of products in your table, I would manually assign the numerical id values to your existing products using your favorite database management tool (phpmyadmin or similar.) To set the next available auto-increment value, you would directly execute a query like: ALTER TABLE your_table_name AUTO_INCREMENT = x; where x is the value you want the table to use for the next row that gets inserted. 3) Now that you have an exiting or a newly added auto-increment column in the table, with values in it, you would just need to use that column name in your queries. Quote Link to comment https://forums.phpfreaks.com/topic/262025-data-not-transferring/#findComment-1343510 Share on other sites More sharing options...
mindapolis Posted May 7, 2012 Author Share Posted May 7, 2012 got it! Thank you so much for all the help! Quote Link to comment https://forums.phpfreaks.com/topic/262025-data-not-transferring/#findComment-1343614 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.