aquatradehub Posted March 1, 2014 Share Posted March 1, 2014 Hi, I have two different pages, where users can sell either items related to the aquatic trade and another where they can sell live_stock. The form for the other items works fine and writes the data to the database using the following functionsregisterTransaction($user_id, $amount, $memo); register_saleItem($sale_data); function register_saleItem($sale_data, $user_id) { array_walk($sale_data, 'array_sanitize'); $fields = '`' . implode('`, `', array_keys($sale_data)) . '`'; $data = '\'' . implode('\', \'', $sale_data) . '\''; mysql_query("INSERT INTO `sales` ($fields) VALUES ($data)"); //email($register_data['email'], 'Activate your account', "Hello " . $register_data['first_name'] . ",\n\nYou need to activate your account, so use the link below:\n\nhttp://localhost/lr/activate.php?email=" . $register_data['email'] . "&email_code=" . $register_data['email_code'] . "\n\n Once activated your account will automatically be credited with 5 welcome credits. \n\n - e-quatics"); } function registerTransaction($user_id, $amount, $memo) { mysql_query("INSERT INTO transaction (user_id, posted_by, amount, datetime, ip, memo) VALUES({$_SESSION['user_id']}, {$_SESSION['user_id']}, $amount, NOW(), '{$_SERVER['REMOTE_ADDR']}','$memo') ") or die(mysql_error()); } This is the first script, the one that works <?php include 'core/init.php'; protect_page(); include 'includes/overall/header.php'; if (empty($_POST) === false) { $required_fields = array('username', 'email', 'category', 'listing_title', 'condition', 'brand', 'model', 'colour', 'quantity', 'price', 'comments', 'postage_type', 'postage_cost'); foreach($_POST as $key=>$value) { if (empty($value) && in_array($key, $required_fields) === true) { $errors[] = 'Fields marked with an asterisk are required'; break 1; } } if (empty($errors) === true) { if(user_exists($_POST['username']) === false) { $errors[] = 'Sorry, the username \'' . $_POST['username'] . '\' does not exist. Have you registered?'; } if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false) { $errors[] = 'A valid email address is required'; } if(empty($category) === false) { $errors[] = 'Please select a category'; } if(empty($listing_title) === false) { $errors[] = 'Please enter a title for your listing'; } if(empty($condition) === false) { $errors[] = 'Please enter a condition'; } if(empty($brand) === false) { $errors[] = 'Please enter a brand'; } if(empty($model) === false) { $errors[] = 'Please enter a model'; } if(empty($colour) === false) { $errors[] = 'Please enter a colour'; } if(empty($quantity) === false) { $errors[] = 'Please enter a quantity'; } if(empty($price) === false) { $errors[] = 'Please enter a price'; } if(empty($comments) === false) { $errors[] = 'Please enter some information about your item'; } if(empty($postage_type) === false) { $errors[] = 'Please enter a postage options'; } if(empty($postage_cost) === false) { $errors[] = 'Please enter the postage cost for this item.'; } } } $bold = $_POST['bold']; $rotate = $_POST['rotate']; $total = $bold + $rotate + 1; $amount = -$total; $query = "SELECT SUM(amount) FROM transaction WHERE user_id = {$_SESSION['user_id']}"; $result = mysql_query($query); if($result) { $row = mysql_fetch_row($result); if($row) { $credits = $row[0]; if ( ($credits - $total) <= 0) { //not enough credits - show message and redirect echo "You either have no remaining credits or not enough to complete this transaction. You will be redirected to purchase more."; header( "Refresh:5; url=purchase.php", true, 303); exit(); } else { //show the form if (isset($_GET['success']) && empty($_GET['success'])) { $username = $user_data['username']; echo '<h2>Thank you for submitting your listing. Your account has been debited.</h2>'; header( "Refresh:5; url=$username", true, 303); } else { if (empty($_POST) === false && empty($errors) === true) { $sale_data = array( 'user_id' => $user_data['user_id'], 'username' => $_POST['username'], 'email' => $_POST['email'], 'category' => $_POST['category'], 'listing_title' => $_POST['listing_title'], 'condition' => $_POST['condition'], 'brand' => $_POST['brand'], 'model' => $_POST['model'], 'colour' => $_POST['colour'], 'quantity' => $_POST['quantity'], 'price' => $_POST['price'], 'comments' => $_POST['comments'], 'postage_type' => $_POST['postage_type'], 'postage_cost' => $_POST['postage_cost'], 'bold' => $_POST['bold'], 'rotate' => $_POST['rotate'] ); } if (empty($_POST) === false && empty($errors) === true) { $memo = "Debit for Item"; registerTransaction($user_id, $amount, $memo); register_saleItem($sale_data); header('Location: other_items.php?success'); exit(); } else if (empty($errors) === false) { echo output_errors($errors); } ?> <script type="text/javascript" src="jquery.js"></script> <form action="" id="sellForm" method="POST"> <input type="hidden" name="username" value="<?php echo $user_data['username']; ?>"></li> <input type="hidden" name="email" value="<?php echo $user_data['email']; ?>"></li> <h2>Sell your item</h2> <p><strong>A basic listing will cost 1 credit - extras will be added to the total cost of your listing</strong></p> <ul> <li>Category*:</br> <select name="category"> <option value="none">--choose--</option> <option value="air_pumps">Air Pumps</option> <option value="air_stones">Air Stones</option> <option value="aquariums">Aquariums</option> <option value="cleaning">Cleaning & Maintenance</option> <option value="equipment">CO2 Equipment</option> <option value="coral">Coral & Live Rock</option> <option value="decorations">Decorations</option> <option value="feeders">Feeders</option> <option value="filter_media">Filter Media & Accessories</option> <option value="food">Food</option> <option value="gravel">Gravel & Substrate</option> <option value="health_care">Health Care</option> <option value="heaters">Heaters & Chillers </option> <option value="lighting">Lighting & Hoods</option> <option value="meters">Meters & Controllers</option> <option value="deionization">Reverse Osmosis & Deionization </option> <option value="tubing">Tubing & Valves</option> <option value="uv">UV Steriliser Water Pumps</option> <option value="water_tests">Water Tests & Treatment</option> <option value="other">Other Fish & Aquarium</option> </select> </li> <li>Listing Title*:</br> <input type="text" name="listing_title"> <li><strong>Would you like your listing displayed in Bold?: <input type="checkbox" name="bold" value="1"/> 1 Credit</strong> </li> <li>Condition*:</br> <select name="condition"> <option>--choose--</option> <option value="New (Packaged)">New (Packaged)</option> <option value="New (None or damaged packaging">New (None or damaged packaging</option> <option value="Used - Working">Used - Working</option> <option value="Used - Not Working">Used - Not Working</option> </select> </li> <li>Brand*:</br> <select name="brand"> <option>Choose...</option> <option value="AI (Aqua Illumination)">AI (Aqua Illumination)</option> <option value="Algarde">Algarde</option> <option value="API">API</option> <option value="AquaEl">AquaEl</option> <option value="AquaGro">AquaGro</option> <option value="Aquamedic">Aquamedic</option> <option value="Aquarian">Aquarian</option> <option value="Aquarium Systems">Aquarium Systems</option> <option value="Aquatlantis">Aquatlantis</option> <option value="Arcadia">Arcadia</option> <option value="Azoo">Azoo</option> <option value="BiOrb/Reef One">BiOrb/Reef One</option> <option value="Blagdon">Blagdon</option> <option value="Boyu">Boyu</option> <option value="Classica">Classica</option> <option value="Cloverleaf">Cloverleaf</option> <option value="Deltec/D-D">Deltec/D-D</option> <option value="Dennerle">Dennerle</option> <option value="Eheim">Eheim</option> <option value="ESHa">ESHa</option> <option value="Hagen/Fluval">Hagen/Fluval</option> <option value="Hikari">Hikari</option> <option value="Hobby">Hobby</option> <option value="Hugo Kamishi">Hugo Kamishi</option> <option value="Interpet">Interpet </option> <option value="JMC">JMC</option> <option value="Juwel">Juwel</option> <option value="King British">King British</option> <option value="New Era">New Era</option> <option value="Nishikoi">Nishikoi</option> <option value="NT Labs">NT Labs</option> <option value="Oase">Oase</option> <option value="Ocean Nutrition">Ocean Nutrition</option> <option value="Penn Plax">Penn Plax</option> <option value="Pontec">Pontec</option> <option value="Red Sea">Red Sea</option> <option value="Rena">Rena</option> <option value="Salifert">Salifert</option> <option value="Seachem">Seachem</option> <option value="Seneye">Seneye</option> <option value="SuperFish">SuperFish</option> <option value="Tanktests">Tanktests</option> <option value="Tetra">Tetra</option> <option value="TMC">TMC</option> <option value="Tunze">Tunze</option> <option value="Two Little Fishies">Two Little Fishies</option> <option value="Waterlife">Waterlife</option> <option value="Wave Point">Wave Point</option> <option value="other">Other</option> </select> </li> <li>Model*:</br> <input type="text" name="model"> </li> <li>Colour*:</br> <select name="colour"> <option value="">--choose one--</option> <option value="White">White</option> <option value="Grey">Grey</option> <option value="Black">Black</option> <option value="Blue">Blue</option> <option value="Green">Green</option> <option value="Orange">Orange</option> <option value="Red">Red</option> <option value="Multicoloured">Multicoloured</option> <option value="Other">Other</option> </select> </li> <li>Quantity*:</br> <select name="quantity"> <option value="">--choose one--</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select><strong> 1 Credit entitles you to sell up to 10 of the same item. </strong> </li> <li>Price*:<br> <input type="text" name="price"> In UK Pound Sterling </li> <li>Description*:</br> <textarea name="comments"></textarea> </li> <li>Postage Type*:</br> <select name="postage_type"> <option>Choose...</option> <option>Choose...</option> <option disabled>Economy services</option> <option value="UK_CollectPlusTracked">Collect+ Economy Tracked (3 to 5 working days)</option> <option value="UK_HermesTracked">Hermes Tracked (3 to 5 working days)</option> <option value="UK_RoyalMailSecondClassStandard">Royal Mail 2nd Class (2 to 3 working days)</option> <option value="UK_RoyalMailSecondClassRecorded">Royal Mail 2nd Class Signed For (2 to 3 working days)</option> <option value="UK_RoyalMailTracked">Royal Mail Tracked 48 (2 to 3 working days)</option> <option value="UK_RoyalMail48">Royal Mail 48 (2 to 3 working days)</option> <option value="UK_OtherCourier3Days">Other Courier 3 days (3 working days)</option> <option value="UK_OtherCourier5Days">Other Courier 5 days (5 working days)</option> <option value="UK_OtherCourier">Other Courier (3 to 5 working days)</option> <option value="UK_SellersStandardRate">Other Courier 3-5 days (3 to 5 working days)</option> <option disabled>Standard services</option> <option value="UK_RoyalMailFirstClassStandard">Royal Mail 1st Class (1 working day)</option> <option value="UK_RoyalMailFirstClassRecorded">Royal Mail 1st Class Signed For (1 working day)</option> <option value="UK_RoyalMailNextDay">Royal Mail Tracked 24 (1 working day)</option> <option value="UK_RoyalMail24">Royal Mail 24 (1 working day)</option> <option value="UK_CollectPlusStandard">Collect+ Standard (2 working days)</option> <option value="UK_Parcelforce48">Parcelforce 48 (1 to 2 working days)</option> <option value="UK_OtherCourier48">Other 48 Hour Courier (1 to 2 working days)</option> <option disabled>Express services</option> <option value="UK_RoyalMailSpecialDeliveryNextDay">Royal Mail Special Delivery (TM) 1:00 pm (1 working day)</option> <option value="UK_RoyalMailSpecialDelivery9am">Royal Mail Special Delivery (TM) 9:00 am (1 working day)</option> <option value="UK_Parcelforce24">Parcelforce 24 (1 working day)</option> <option value="UK_OtherCourier24">Other 24 Hour Courier (1 working day)</option> <option disabled>Services from outside UK</option> <option value="UK_EconomyShippingFromOutside">Economy Delivery from outside UK (10 to 22 working days)</option> <option value="StandardDeliveryfromOutsideUKwithRoyalMail">Standard Delivery from outside UK with Royal Mail (7 to 13 working days)</option> <option value="UK_StandardShippingFromOutside">Standard Delivery from outside UK (4 to 10 working days)</option> <option value="UK_ExpeditedShippingFromOutside">Express Delivery from outside UK (1 to 3 working days)</option> <option value="UK_FedExIntlEconomy">FedEx International Economy (3 to 4 working days)</option> <option value="UK_TntIntlExp">TNT International Express (2 to 3 working days)</option> <option value="UK_TrackedDeliveryFromAbroad">Tracked delivery from outside UK (2 to 5 working days)</option> <option disabled>Collection</option> <option value="UK_CollectInPerson">Collection in Person </option> </select> </li> <li>Postage Cost*:</br> <input type="text" name="postage_cost"> </li> </ul> <ul> <li>Upload Photo:</br> <input id="file" type="file" name="uploadPhoto"> </li> <li><input type="checkbox" name="rotate" value="10"/><strong>For 10 credits, you can have your listing displayed on our homepage on a rotation basis. </strong> </li> <li> <input type="submit" value="List Item"></li> </ul> </form> <?php } } } else { echo 'no row'; } } else { echo ' query unsuccessful'; } include 'includes/overall/footer.php'; ?> Now the live stock page uses the following two functions to write the data to the database function register_LiveSaleItem($sale_data, $user_id) { array_walk($sale_data, 'array_sanitize'); $fields = '`' . implode('`, `', array_keys($live_sale_data)) . '`'; $data = '\'' . implode('\', \'', $live_sale_data) . '\''; mysql_query("INSERT INTO `live_sales` ($fields) VALUES ($data)"); //email($register_data['email'], 'Activate your account', "Hello " . $register_data['first_name'] . ",\n\nYou need to activate your account, so use the link below:\n\nhttp://localhost/lr/activate.php?email=" . $register_data['email'] . "&email_code=" . $register_data['email_code'] . "\n\n Once activated your account will automatically be credited with 5 welcome credits. \n\n - e-quatics"); } function registerTransaction($user_id, $amount, $memo) { mysql_query("INSERT INTO transaction (user_id, posted_by, amount, datetime, ip, memo) VALUES({$_SESSION['user_id']}, {$_SESSION['user_id']}, $amount, NOW(), '{$_SERVER['REMOTE_ADDR']}','$memo') ") or die(mysql_error()); } and here is the script <?php include 'core/init.php'; protect_page(); include 'includes/overall/header.php'; if (empty($_POST) === false) { $required_fields = array('username', 'email', 'fishtype', 'speciesCommon', 'speciesScientific', 'listing_title', 'age', 'quantity', 'origin', 'size', 'environment', 'waterChemistry', 'temperature', 'feeding', 'sexing', 'compatability', 'temperament', 'breeding', 'comments', 'postage_type', 'postage_cost'); foreach($_POST as $key=>$value) { if (empty($value) && in_array($key, $required_fields) === true) { $errors[] = 'Fields marked with an asterisk are required.'; break 1; } } if (empty($errors) === true) { if(user_exists($_POST['username']) === false) { $errors[] = 'Sorry, the username \'' . $_POST['username'] . '\' does not exist. Have you registered?'; } if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false) { $errors[] = 'A valid email is required'; } if(empty($fishtype) === false) { $errors[] = 'Please select a category'; } if(empty($listing_title) === false) { $errors[] = 'Please select a title for your listing'; } if(empty($age) === false) { $errors[] = 'Please select a age'; } if(empty($quantity) === false) { $errors[] = 'Please select a quantity'; } if(empty($origin) === false) { $errors[] = 'Please select a origin'; } if(empty($size) === false) { $errors[] = 'Please select a size'; } if(empty($environment) === false) { $errors[] = 'Please select a environment'; } if(empty($waterChemistry) === false) { $errors[] = 'Please select a water chemistry'; } if(empty($temperature) === false) { $errors[] = 'Please select a temperature'; } if(empty($feeding) === false) { $errors[] = 'Please select a feeding'; } if(empty($sexing) === false) { $errors[] = 'Please select a sexing'; } if(empty($compatability) === false) { $errors[] = 'Please select a compatability'; } if(empty($temperament) === false) { $errors[] = 'Please select a temperament'; } if(empty($breeding) === false) { $errors[] = 'Please enter some information on breeding'; } if(empty($comments) === false) { $errors[] = 'Please enter some comments'; } if(empty($postage_type) === false) { $errors[] = 'Please enter a postage type'; } if(empty($postage_cost) === false) { $errors[] = 'Please enter a postage cost'; } } } $bold = $_POST['bold']; $rotate = $_POST['rotate']; $total = $bold + $rotate + 1; $amount = -$total; $query = "SELECT SUM(amount) FROM transaction WHERE user_id = {$_SESSION['user_id']}"; $result = mysql_query($query); if($result) { $row = mysql_fetch_row($result); if($row) { $credits = $row[0]; if ( ($credits - $total) <= 0) { //not enough credits - show message and redirect echo "You either have no remaining credits or not enough to complete this transaction. You will be redirected to purchase more."; header( "Refresh:5; url=purchase.php", true, 303); exit(); } else { //show the form if (isset($_GET['success']) && empty($_GET['success'])) { $username = $user_data['username']; echo '<h2>Thank you for submitting your listing. Your account has been debited.</h2>'; header( "Refresh:5; url=$username", true, 303); } else { if (empty($_POST) === false && empty($errors) === true) { $live_sale_data = array( 'user_id' => $user_data['user_id'], 'username' => $user_data['username'], 'email' => $user_data['email'], 'fishtype' => $user_data['fishtype'], 'speciesCommon' => $user_data['speciesCommon'], 'speciesScientific' => $user_data['speciesScientific'], 'listing_title' => $user_data['listing_title'], 'age' => $user_data['age'], 'quantity' => $user_data['quantity'], 'origin' => $user_data['origin'], 'size' => $user_data['size'], 'environment' => $user_data['environment'], 'waterChemistry' => $user_data['waterChemistry'], 'temperature' => $user_data['temperature'], 'feeding' => $user_data['feeding'], 'sexing' => $user_data['sexing'], 'compatability' => $user_data['compatability'], 'temperament' => $user_data['temperament'], 'breeding' => $user_data['breeding'], 'comments' => $user_data['comments'], 'postage_type' => $user_data['postage_type'], 'postage_cost' => $user_data['postage_cost'], 'bold' => $user_data['bold'], 'rotate' => $user_data['rotate'] ); } if (empty($_POST) === false && empty($errors) === true) { $memo = "Debit for Item"; register_LiveSaleItem($live_sale_data); registerTransaction($user_id, $amount, $memo); header('Location: sell_live.php?success'); exit(); } else if (empty($errors) === false) { echo output_errors($errors); } ?> <script type="text/javascript" src="jquery.js"></script> <form action="" id="sellForm" method="POST"> <input type="hidden" name="username" value="<?php echo $user_data['username']; ?>"></li> <input type="hidden" name="email" value="<?php echo $user_data['email']; ?>"></li> <h2>Sell your item</h2> <p><strong>A basic listing will cost 1 credit - extras will be added to the total cost of your listing</strong></p> <ul> <li>Category*:</br> <select name="fishtype"> <option value="none">--choose--</option> <option value="cichlids">Cichlids</option> <option value="tropical_fish">Tropical Fish</option> <option value="tropical_shrimp">Tropical Shrimp</option> <option value="tropical_frogs">Tropical Frogs</option> <option value="tropical_snails">Tropical Snails</option> <option value="marine_fish">Marine Fish</option> <option value="marine_shrimp"> Marine Shrimp</option> <option value="marine_snails"> Marine Snails</option> </select> </li> <li>Sub Category*:</br> <select name="speciesCommon"> <option value="">--choose one--</option> </select> </li> <li>Sub Category*:</br> <select name="speciesScientific"> <option value="">--choose one--</option> </select> </li> <li>Listing Title*:</br> <input type="text" name="listing_title"> <li><strong>Would you like your listing displayed in Bold?: <input type="checkbox" name="bold" value="1"/> 1 Credit</strong> </li> <li>Age*:</br> <select name="age"> <option>--choose one--...</option> <option value="0-6 months">0-6 months</option> <option value="6-12 months">6-12 months</option> <option value="1-2 years">1-2 years</option> <option value="2-3 years">2-3 years</option> <option value="3-4 years">3-4 years</option> <option value="4-5 years">4-5 years</option> <option value="5-6 years">5-6 years</option> <option value="6-7 years">6-7 years</option> <option value="7-8 years">7-8 years</option> <option value="8-9 years">9-10 years</option> <option value="11-12 years">11-12 years</option> <option value="13-14 years">13-14 years</option> <option value="15-16 years">15-16 years</option> <option value="16-17 years">16-17 years</option> <option value="18-19 years">18-19 years</option> <option value="19-20+ years">19-20+ years</option> <option value="Unknown">Unknown</option> </select> <li>Quantity*:</br> <select name="quantity"> <option>--choose one--...</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select><strong> 1 Credit entitles you to sell up to 10 of the same item. </strong> </li> <li>Origin*:</br> <select multiple name="origin"> <option>--choose one--...</option> <option value="North America">North America</option> <option value="Central America">Central America</option> <option value="South America">South America</option> <option value="Caribbean">Caribbean</option> <option value="Central Africa">Central Africa</option> <option value="East Africa">East Africa</option> <option value="West Africa">West Africa</option> <option value="Southeast Asia">Southeast Asia</option> <option value="India">India</option> </select> </li> <li>Size*:</br> <select name="size"> <option>Choose...</option> <option value="1cm">1cm</option> <option value="2cm">2cm</option> <option value="3cm">3cm</option> <option value="4cm">4cm</option> <option value="5cm">5cm</option> <option value="6cm">6cm</option> <option value="7cm">7cm</option> <option value="8cm">8cm</option> <option value="9cm">9cm</option> <option value="10cm">10cm</option> <option value="11cm">11cm</option> <option value="12cm">12cm</option> <option value="13cm">13cm</option> <option value="14cm">14cm</option> <option value="15cm">15cm</option> <option value="16cm">16cm</option> <option value="17cm">17cm</option> <option value="18cm">18cm</option> <option value="19cm">19cm</option> <option value="20cm">20cm</option> <option value="21cm">21cm</option> <option value="22cm">22cm</option> <option value="23cm">23cm</option> <option value="24cm">24cm</option> <option value="25cm">25cm</option> <option value="26cm">26cm</option> <option value="27cm">27cm</option> <option value="28cm">28cm</option> <option value="29cm">29cm</option> <option value="30cm">30cm</option> <option value="31cm">31cm</option> <option value="32cm">32cm</option> <option value="33cm">33cm</option> <option value="34cm">34cm</option> <option value="35cm">35cm</option> <option value="36cm">36cm</option> <option value="37cm">37cm</option> <option value="38cm">38cm</option> <option value="39cm">39cm</option> <option value="40cm">40cm</option> <option value="41cm">41cm</option> <option value="42cm">42cm</option> <option value="43cm">43cm</option> <option value="44cm">44cm</option> <option value="45cm">45cm</option> <option value="46cm">46cm</option> <option value="47cm">47cm</option> <option value="48cm">48cm</option> <option value="49cm">49cm</option> <option value="50cm">50cm</option> <option value="51cm">51cm</option> <option value="52cm">52cm</option> <option value="53cm">53cm</option> <option value="54cm">54cm</option> <option value="55cm">55cm</option> <option value="56cm">56cm</option> <option value="57cm">57cm</option> <option value="58cm">58cm</option> <option value="59cm">59cm</option> <option value="60cm">60cm</option> <option value="61cm">61cm</option> <option value="62cm">62cm</option> <option value="63cm">63cm</option> <option value="64cm">64cm</option> <option value="65cm">65cm</option> <option value="66cm">66cm</option> <option value="67cm">67cm</option> <option value="68cm">68cm</option> <option value="69cm">69cm</option> <option value="70cm">70cm</option> <option value="over 70cm">70cm+</option> </select> </li> </ul> <h2>Environment</h2> <ul> <li>Lakes: <input type="checkbox" name="environment" value="lakes"/> Ponds: <input type="checkbox" name="environment" value="ponds"/> Rivers: <input type="checkbox" name="environment" value="rivers"/> Streams: <input type="checkbox" name="environment" value="streams"/> Sea: <input type="checkbox" name="environment" value="sea"/></li> </ul> <ul> <li>Water Chemistry*:</br> <select name="waterChemistry" id="waterChemistry"> <option>Choose...</option> <option value="Very Soft">Very Soft</option> <option value="Soft">Soft</option> <option value="Medium Hard">Medium Hard</option> <option value="Hard">Hard</option> <option value="Very Hard">Very Hard</option> </select> </li> <li>Temperature*:</br> <select name="temperature"> <option>Choose...</option> <option value="20-22oC">20-22oC</option> <option value="22-24oC">22-24oC</option> <option value="24-26oC">24-26oC</option> <option value="26-28oC">26-28oC</option> <option value="28-30oC">28-30oC</option> </select> </li> <li>Feeding*:</br> <textarea name="feeding"/></textarea> </li> <li>Sexing*:</br> <textarea name="sexing"></textarea> </li> <li>Compatability*:</br> <textarea name="compatibility"></textarea> </li> <li>Temperament*:</br> <select name="temperament"> <option>Choose...</option> <option value="peaceful">Peaceful</option> <option value="Semi-Aggressive">Semi-Aggressive</option> <option value="Aggressive">Aggressive</option> </select> </li> <li>Breeding*:</br> <textarea name="breeding"></textarea> </li> <li>Comments*:</br> <textarea name="comments"></textarea> </li> <li>Postage Type*:</br> <select name="postage_type"> <option>Choose...</option> <option>Choose...</option> <option disabled>Economy services</option> <option value="UK_CollectPlusTracked">Collect+ Economy Tracked (3 to 5 working days)</option> <option value="UK_HermesTracked">Hermes Tracked (3 to 5 working days)</option> <option value="UK_RoyalMailSecondClassStandard">Royal Mail 2nd Class (2 to 3 working days)</option> <option value="UK_RoyalMailSecondClassRecorded">Royal Mail 2nd Class Signed For (2 to 3 working days)</option> <option value="UK_RoyalMailTracked">Royal Mail Tracked 48 (2 to 3 working days)</option> <option value="UK_RoyalMail48">Royal Mail 48 (2 to 3 working days)</option> <option value="UK_OtherCourier3Days">Other Courier 3 days (3 working days)</option> <option value="UK_OtherCourier5Days">Other Courier 5 days (5 working days)</option> <option value="UK_OtherCourier">Other Courier (3 to 5 working days)</option> <option value="UK_SellersStandardRate">Other Courier 3-5 days (3 to 5 working days)</option> <option disabled>Standard services</option> <option value="UK_RoyalMailFirstClassStandard">Royal Mail 1st Class (1 working day)</option> <option value="UK_RoyalMailFirstClassRecorded">Royal Mail 1st Class Signed For (1 working day)</option> <option value="UK_RoyalMailNextDay">Royal Mail Tracked 24 (1 working day)</option> <option value="UK_RoyalMail24">Royal Mail 24 (1 working day)</option> <option value="UK_CollectPlusStandard">Collect+ Standard (2 working days)</option> <option value="UK_Parcelforce48">Parcelforce 48 (1 to 2 working days)</option> <option value="UK_OtherCourier48">Other 48 Hour Courier (1 to 2 working days)</option> <option disabled>Express services</option> <option value="UK_RoyalMailSpecialDeliveryNextDay">Royal Mail Special Delivery (TM) 1:00 pm (1 working day)</option> <option value="UK_RoyalMailSpecialDelivery9am">Royal Mail Special Delivery (TM) 9:00 am (1 working day)</option> <option value="UK_Parcelforce24">Parcelforce 24 (1 working day)</option> <option value="UK_OtherCourier24">Other 24 Hour Courier (1 working day)</option> <option disabled>Services from outside UK</option> <option value="UK_EconomyShippingFromOutside">Economy Delivery from outside UK (10 to 22 working days)</option> <option value="StandardDeliveryfromOutsideUKwithRoyalMail">Standard Delivery from outside UK with Royal Mail (7 to 13 working days)</option> <option value="UK_StandardShippingFromOutside">Standard Delivery from outside UK (4 to 10 working days)</option> <option value="UK_ExpeditedShippingFromOutside">Express Delivery from outside UK (1 to 3 working days)</option> <option value="UK_FedExIntlEconomy">FedEx International Economy (3 to 4 working days)</option> <option value="UK_TntIntlExp">TNT International Express (2 to 3 working days)</option> <option value="UK_TrackedDeliveryFromAbroad">Tracked delivery from outside UK (2 to 5 working days)</option> <option disabled>Collection</option> <option value="UK_CollectInPerson">Collection in Person </option> </select> </li> <li>Postage Cost*:</br> <input type="text" name="postage_cost"> </li> </ul> <ul> <li><input type="checkbox" name="rotate" value="10"/>For 10 credits, you can have your listing displayed on our homepage on a rotation basis. </li> <li> <input type="submit" value="List Item"> </li> </ul> </form> <script type="text/javascript" src="saleSpecies.js"></script> <?php } } } else { echo 'no row'; } } else { echo 'query unsuccessful'; } include 'includes/overall/footer.php'; ?> register_LiveSaleItem($live_sale_data); creates a row in the live_sales database and contains the information from 'user_id' => $user_data['user_id'],'username' => $user_data['username'],'email' => $user_data['email'],and the AUTO INCREMENTED sale_id is created for each entry, but none of the other $live_sale_data data is contained in the row. However the registerTransaction($user_id, $amount, $memo); works fineCan anyone see where I have gone wrong?Many Thanksaquaman Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted March 1, 2014 Share Posted March 1, 2014 there's really no way that the code you posted for the register_LiveSaleItem() function is the actual code. it contains an obvious name mismatch between the defined parameter names and the variables being used in the function code. also, why are you defining the $user_id as a parameter but not using it in the function or suppling it when you call your function? there would be a number of php errors from that code (do you have php's error_reporting/display_errors turned on so that php will help you?) here's hint as well. the only difference between the code for the register_saleItem() and register_LiveSaleItem() functions is the database table name it uses. instead of having two different functions, why not just have one function that accepts the table name as a call time parameter. Quote Link to comment Share on other sites More sharing options...
Solution aquatradehub Posted March 2, 2014 Author Solution Share Posted March 2, 2014 Hi thanks for your reply, I sorted it, the live_sale_data should have read $_POST['fishtype'], and the function was missing the live_ in front of sale_data Doh! 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.