Jump to content

SmileyWar

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

SmileyWar's Achievements

Member

Member (2/5)

0

Reputation

  1. Hello Pickachu2000 Offcourse that makes sense now, thanks very much! I was banging my head all day long researching why column names didn't respond! hahaha. You learn something new every day
  2. Hello all, This is a odd one, last year i built a query where i was pretty new to mysql, and what i did was as simple as this. Get the query and then print the data. But now that i'm updating the database i absolutely hate having to use numbers because i want to reorder the table. But when i want to change it to column names it's not getting the data. And i can't understand why that's happening. Here is what i have. $op1 = mysql_query("SELECT * FROM carchain_prices_qty WHERE ProductID='".$option1."' ", $connect) or die(mysql_error()); $product1 = mysql_fetch_row($op1); if ($options >= "1"){ echo' <li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-1"><a href="#fragment-1"> <center> <img src="images/preview_'.$product1[8].'_small.jpg" alt="'.$product1[1].'" title="'.$product1[1].'" /> </center> <span> £ '.$product1[2].' per pair<br> '.$product1[9].'<br>'.$product1[10].' </span> </a></li> '; } and here is what i want it to be, noting that all my newly designed scripts are always with column names, it's only that first one i built due to the same issue i have now i used numbers in the array rather then names if ($options >= "1"){ echo' <li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-1"><a href="#fragment-1"> <center> <img src="images/preview_'.$product1['PageID'].'_small.jpg" alt="'.$product1['ProductID'].'" title="'.$product1['ProductID'].'" /> </center> <span> £ '.$product1['Price'].' per pair<br> '.$product1['ProductBrand'].'<br>'.$product1['ProductName'].' </span> </a></li> '; } Your wisdom is much appreciated, thanks!
  3. Hiya CPD, thank you for your continued support, i ended up pointing the sessions to the tmp folder in the php.ini file, as it seems it didn't save the sessions correctly.
  4. Ill have to get in contact with MT i think there might be a tmp save problem anybody else known of this issue running PHP Version 5.3.13
  5. Hiya, Thanks for the reply, indeed there is no check on the login file thanks for pointing that out. Will update that. Regarding the other page it is very very odd, i have now with the help of the session dump, figured out that it shows the sessions, then it's gone, then after a couple of minutes it's there again and so on... I cant understand how that is even possible???
  6. When i tried to retrieve the session data after that quirky effect, the session['WSvalidUser'] was null, this can only happen if the user is invalid or that the session['WSuser'] is empty. But after i relogged in all session data is there. So as far as i can tell the session is definitely not expired, otherwise session['WSvalidUser'] would be expired too. So it seems that when refreshing something its clearing the session['WSuser'] What i will do now is write some other sessions see if they are still there, after it looses WSuser session I'll keep post back soon with the update and if it worked what im planning.
  7. For some reason my session's gets lost randomly, or my scripting is buggy. When i hit refresh it just looses the session, how can i debug this? Here is the login script. Which then redirects to the homepage which has the following code
  8. I singled out the script to run on itself without any problems. So i'll have to look somewhere else. I'll close this topic for now.
  9. Ether i'm extremely tired, or i'm just not seeing my mistakes. But i can't capture the multi arrays for some reason. The jQuery script works correct. It's just the foreach is not working, i don't think i have the form wrong. Any help would be much appreciated, thanks. Form on the site <?php echo '<form method="POST" name="addItems" id="addItems12" action="#">'; echo '<input type="hidden" name="sessionID" value="'.session_id().'" />'; echo '<input type="hidden" name="newMultiProducts" />'; echo '<input type="hidden" name="productReturnURL" value="Products/Selection/" />'; echo '<input type="hidden" name="item[0][productDescription]" value="Rapid Fit Foot Pack" />'; echo '<input type="hidden" name="item[0][productID]" value="'.$mysql_footpack.'" />'; echo '<input type="hidden" name="item[0][productLink]" value="'.$curURL.'" />'; echo '<input type="hidden" name="item[0][productPrice]" value="'.$_footpack_single_price.'" />'; echo '<input type="hidden" name="item[0][productShipping]" value="A" />'; echo '<input type="hidden" name="item[0][productThumb]" value="'.$mysql_footpack.'" />'; echo '<input type="checkbox" name="item[0][productQuantity]" class="productQuantity" value="1" onClick="toggle(this, \'keynumber_field1\')" />'; echo '<input type="hidden" name="item[1][productDescription]" value="Rapid Fit Foot Pack" />'; echo '<input type="hidden" name="item[1][productID]" value="sh_'.$mysql_footpack.'" />'; echo '<input type="hidden" name="item[1][productLink]" value="'.$curURL.'" />'; echo '<input type="hidden" name="item[1][productPrice]" value="'.$_footpack_single_2ndhand_price.'" />'; echo '<input type="hidden" name="item[1][productShipping]" value="A" />'; echo '<input type="hidden" name="item[1][productThumb]" value="'.$mysql_footpack.'" />'; echo '<input type="checkbox" name="item[1][productQuantity]" class="productQuantity" value="1" onClick="toggle(this, \'keynumber_field2\')" />'; echo '<input name="add_to_basket" type="image" id="submit12" src="img/addtobasket_new.png" alt="Click here to add items to your shopping basket" />'; echo '</form>'; ?> jQuery $(document).ready(function() { $("#submit12").click(function(){ $(".preloaderMiniBasketBG").fadeIn(300); $('.preloaderMiniBasket').html('<img src="images/styling/preloaderTP.gif" />'); $.ajax({ type: "POST", url: "Shopping/json.php", data: $("#addItems12").serialize(), dataType: "json", success: function(data){ /* if (data.productReturnURL){ window.location.href = data.productReturnURL; } */ console.log(data); $('#miniBasket').html(data.miniBasket); $('#miniBasketDetails').html(data.miniBasketDetails); $('.preloaderMiniBasket').html(''); $(".preloaderMiniBasketBG").fadeOut(300); $("#miniBasketPopup").fadeIn(300); setTimeout(function() { $("#miniBasketPopup").fadeOut(2500); },5000); } }); return false; }); }); the script that runs the foreach foreach($_POST['item'] as $key => $value) { $productDescription = $value['productDescription']; $productID = $value['productID']; $productKeyNumber = $value['productKeyNumber']; $productLink = $value['productLink']; $productPrice = $value['productPrice']; $productQuantity = $value['productQuantity']; $productShipping = $value['productShipping']; $productThumb = $value['productThumb']; }
  10. Hello Barand, i have changed all the header locations with double quotations and stripped the escapes around the variables. It works as it should do at the moment. If this works for the future, thank you very much for your help (Does not mean i'm already great full of your help ) If not i'll come back with hopefully more explanation with my testing when it stops working again. As of now, i'll set this topic to solved.
  11. Hi guys, i'm having trouble with a script after MT updated the php version to PHP 5.3.10 The script sometimes will not work, while it did not work i managed to eliminated the script which didnt work. But after echoing parts to see what worked and what not, it starting working again. So i was not able to finish my tests. I read time over time into my script and as far as i can tell i cant figure out what is causing it not to work. I assume it's the header location as it should always redirect the page in any given situation. Anybody else having header location fluctuation or am i having different problems? Any help would be appreciated. if ($check_voters >= '1'){ $last = mysql_query("SELECT * FROM check_voters WHERE ip='".$ip."' ORDER BY id DESC LIMIT 1") or die(mysql_error()); $row = mysql_fetch_array( $last ) or die(mysql_error()); if ($row['date'] == $date){ list($hours, $minutes) = split(':', $row['time']); $startTimestamp = (($hours * '60') + $minutes); list($hours, $minutes) = split(':', $time); $endTimestamp = (($hours * '60') + $minutes); $timeDif = ($endTimestamp - $startTimestamp); if ($timeDif <= '1500'){ function encryptStringArray ($stringArray, $key = "some hashes") { $s = strtr(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), serialize($stringArray), MCRYPT_MODE_CBC, md5(md5($key)))), '+/=', '-_,'); return $s; } $encoded = encryptStringArray($timeDif ); $woops = $encoded.':casted'; header('Location: page.php?woops='.$woops.''); }else{ mysql_query("INSERT INTO check_voters (id, ip, date, time) VALUES ('', '".$ip."', '".$date."', '".$time."')") or die(mysql_error()); # update visitors mysql_query("INSERT INTO visitors (id, category, efface, ip, browser, hostaddress, referred, country, date, time) VALUES ('', '".$catergory."', '".$q."', '".$ip."', '".$browser."', '".$hostaddress."', '".$referred."', '".$country."', '".$date."', '".$time."')") or die(mysql_error()); $q_list = "SELECT COUNT(*) FROM list WHERE efface='".$q."'"; $r_list = mysql_query($q_list) or die(mysql_error()); $t_r_list = mysql_fetch_row($r_list); $check_list = $t_r_list[0]; if ($check_list >= '1'){ $a = '1'; $check_fetch = mysql_query("SELECT * FROM list WHERE efface='".$q."'") or die(mysql_error()); $check_row = mysql_fetch_array( $check_fetch ) or die(mysql_error()); $new_number = ($check_row['votes'] + $a); mysql_query("UPDATE list SET votes='".$new_number."' WHERE efface='".$q."'"); }else{ mysql_query("INSERT INTO list (id, category, efface, votes) VALUES ('', '".$catergory."', '".$q."','1')"); } # insert matched word into database mysql_query("INSERT INTO results (id, word, category, span) VALUES ('', '".$subject."', '".$category."', '".$characters."')"); header('Location: page.php?efface='.$subject.''); } } }else{ mysql_query("INSERT INTO check_voters (id, ip, date, time) VALUES ('', '".$ip."', '".$date."', '".$time."')") or die(mysql_error()); # update visitors mysql_query("INSERT INTO visitors (id, category, efface, ip, browser, hostaddress, referred, country, date, time) VALUES ('', '".$catergory."', '".$q."', '".$ip."', '".$browser."', '".$hostaddress."', '".$referred."', '".$country."', '".$date."', '".$time."')") or die(mysql_error()); $q_list = "SELECT COUNT(*) FROM list WHERE efface='".$q."'"; $r_list = mysql_query($q_list) or die(mysql_error()); $t_r_list = mysql_fetch_row($r_list); $check_list = $t_r_list[0]; if ($check_list >= '1'){ $z = '1'; $check_fetch = mysql_query("SELECT * FROM list WHERE efface='".$q."'") or die(mysql_error()); $check_row = mysql_fetch_array( $check_fetch ) or die(mysql_error()); $new_number = ($check_row['votes'] + $a); mysql_query("UPDATE list SET votes='".$new_number."' WHERE efface='".$q."'"); }else{ mysql_query("INSERT INTO list (id, category, efface, votes) VALUES ('', '".$catergory."', '".$q."','1')"); } mysql_query("INSERT INTO results (id, word, category, span) VALUES ('', '".$subject."', '".$category."', '".$characters."')"); header('Location: page.php?efface='.$subject.''); }
  12. Excellent scootstah, thank you very much for explaining, much appreciated i did not know you could parse data to hidden fields I'm still a jquery noobie the following code helped me for people who are interested. $('input[id=price]').val(data);
  13. Another thing i was thinking was to have jquery to load the information from the same page then place an if (!isset($_POST['productID']) but i'm was not succesfull in getting jquery to load the information from the same page which is possible with php but on refresh page. the following code is with the query on the same page with !isset, any idea's on this concept? But then it i'm unsure if it would update the variable <?php if (!isset($_POST['productID']){ $productID = $_POST['productID']; include_once($_SERVER['DOCUMENT_ROOT'] ."include/mysql_connect.php"); $result = mysql_query("SELECT * FROM products_prices WHERE product='".$productID."'") or die(mysql_error()); $row = mysql_fetch_array($result); echo $row['price']; $$get[$i]['price'] = $row['price']; mysql_close($connect); } ?> <script type="text/javascript"> $(document).ready(function() { $.post('#', $("#productPrice").serialize(), function(data) { $('.dynamicprice').html(data); }); $("#productPrice").change(function(){ $.post('#', $("#productPrice").serialize(), function(data) { $('.dynamicprice').html(data); }); }); }); </script>
  14. I'm not sure i understand what you mean? Just as a sidenote, i originally wanted to use json to return information but its also echo'd so not placed in a variable. As an addition i wanted to update prices without refreshing the page.
  15. Hiya guys, I'm stuck, my initial idea is to dynamically from on original state and selection change to update a price change from mysql. Here is what i have which works, but i cant seem to get the price for my submit button as the jquery sends the price in a div class which cant be placed in a form element, so i was trying to find out if can change the jquery code to place it in a php variable. Btw i just started out with jquery so im still clueless i want the input field to update dynamically too <input type='hidden' name='product_cost' value='<?php echo $get[$i]['price']; ?>' /> This code is inserted on hundreds of pages and the id is changed plus other options which will trigger a result in the included script <?php if ($i == NULL){$i = "1";} /////////////////////// ONLY MODIFY THIS SECTION ////////////////////// /////////////////////////////////////////////////////////////////////// $p[$i] = "532"; /// Insert Product ID ${pkey_.$i} = "yes"; /// Add keynumber field? yes or no ${poptions_.$i} = "(1)"; /// Set Minimum Start Number of Quantity || (1) means only one option ${return_url_.$i} = "mof"; /// cururl = return to current url || mof = alternate page in mof ${dynamic_prices_.$i} = "yes"; /// Dynamic prices are prices that change upon interaction with viewer set "yes" or "no" /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// include($_SERVER['DOCUMENT_ROOT'] ."/product_include/script2.php"); #Scripts INCLUDE ?> this is the included script which displays the results <script type="text/javascript"> $(document).ready(function() { $.post('get_dynamic_prices.php', $("#productPrice").serialize(), function(data) { $('.dynamicprice').html(data); }); $("#productPrice").change(function(){ $.post('get_dynamic_prices.php', $("#productPrice").serialize(), function(data) { $('.dynamicprice').html(data); }); }); }); </script> <?php ///////////// # DO NOT MODIFY BELOW # ///////////// $url = curPageURL(); $result[$i] = mysql_query("SELECT * FROM products_prices WHERE product='".$p[$i]."' ",$connect) or die(mysql_error()); $get[$i] = mysql_fetch_array($result[$i]); if ($get[$i]['quantity'] > "0"){${switch1_.$i} = ""; ${switch2_.$i} = "none";} else{${switch1_.$i} = "none"; ${switch2_.$i} = "";} if (${pkey_.$i} == "yes"){${switch_col_.$i} = ""; ${switch_colspan_.$i} = "5";} elseif (${pkey_.$i} == "no"){${switch_col_.$i} = "none"; ${switch_colspan_.$i} = "4";} if (${return_url_.$i} == "cururl"){${r_url_.$i} = $url;} elseif (${return_url_.$i} == "mof"){${r_url_.$i} = "/mof/".$get[$i]['product']."_mof.php";} else {${r_url_.$i} = $url;} ?> <style type="text/css"> .robot { /*display : none ; */ } </style> <div id="emailme-<?php echo $i; ?>" style="display:none;"> <div class="chain-email-me-popup"> <h1 class="chain-email-me-popup-h1">Contact me when in stock</h1> <div class="chain-email-me-form"> Thank you for your interest in <?php echo "Thule ".$get[$i]['product']." ".$get[$i]['description'].""; ?>.<br /><br /> Please complete your details. *All fields below required<br /><br /> <form name="emailme" action="/emailme/index2.php" method="POST"> <label for="firstname">Firstname*</label><br /> <input value="" name="fname" /><br /> <label for="sname">Surname*</label><br /> <input value="" name="sname" /><br /> <label for="email">Email Address*</label><br /> <input value="" name="email" /><br /><br /> <input type="hidden" name="productID" value="<?php echo $get[$i]['product']; ?>" /> <input type="hidden" name="productBrand" value="Thule" /> <input type="hidden" name="productDescription" value="<?php echo $get[$i]['description']; ?>" /> <input type="hidden" name="productURL" value="<?php echo $url; ?>" /> <div class="robot"> <p>Please don't change the next two fields. It's only to avoid spam</p> <input type="text" name="address2" id="address2" value="sfjli"> <input type="text" name="address3" id="address3" value=""> </div> <input type="submit" value="Submit"><br /> </form> <br /><br /> We'll only use your details to contact you about this product, and not for marketing purposes. </div> </div> </div> <?php // Dynamic prices opening or closing form field if (${dynamic_prices_.$i} == "yes") { echo ''; } elseif (${dynamic_prices_.$i} == "no") { echo ' <form method=POST action="/basket/basket.php"> <input type="hidden" name="type" value="single"> <input type="hidden" name="product_link" value="'.$url.'" /> <input type="hidden" name="return_url" value="'.${r_url_.$i}.'" /> '; } // fallback for older includes else { echo ' <form method=POST action="/basket/basket.php"> <input type="hidden" name="type" value="single"> <input type="hidden" name="product_link" value="'.$url.'" /> <input type="hidden" name="return_url" value="'.${r_url_.$i}.'" /> '; } ?> <table class="P5-table"> <tr> <td class="P-description" colspan="<?php echo ${switch_colspan_.$i}; ?>"> <?php echo $get[$i]['notes1']; ?> <em><?php echo $get[$i]['notes2']; ?></em> <span><?php echo $get[$i]['notes3']; ?></span> </td> </tr> <tr> <td class="P5-qty" style="display:<?php echo ${switch1_.$i}; ?>"> <?php if (${dynamic_prices_.$i} == "yes"){ echo ' <form name="productPrice" id="productPrice" action="" method="POST"> <label for="productID">Select Qty</label> <select name="productID" id="productID"> <option value="532-s">1 </option> <option value="532-tp">2</option> <option value="532-3">3</option> <option value="532-4">4</option> <option value="532-5">5</option> <option value="532-6">6</option> </select> </form> '; } elseif (${dynamic_prices_.$i} == "no"){ echo '<select name="product_quantity" size="1"><option value="'; if (${poptions_.$i} == "(1)"){echo "1";}elseif (${poptions_.$i} == "evennumbers"){echo "2";} else{ echo ${poptions_.$i};} echo '">Qty </option>'; if (${poptions_.$i} == "1"){echo '<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>';} if (${poptions_.$i} == "2"){echo '<option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option>';} if (${poptions_.$i} == "3"){echo '<option value="3">3</option><option value="4">4</option><option value="5">5</option>';} if (${poptions_.$i} == "4"){echo '<option value="4">4</option><option value="5">5</option>';} if (${poptions_.$i} == "5"){echo '<option value="5">5</option>';} if (${poptions_.$i} == "(1)"){echo '<option value="1">1</option>';} echo '</select>'; } // fallback for older includes else { echo '<select name="product_quantity" size="1"><option value="'; if (${poptions_.$i} == "(1)"){echo "1";}elseif (${poptions_.$i} == "evennumbers"){echo "2";} else{ echo ${poptions_.$i};} echo '">Qty </option>'; if (${poptions_.$i} == "1"){echo '<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>';} if (${poptions_.$i} == "2"){echo '<option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option>';} if (${poptions_.$i} == "3"){echo '<option value="3">3</option><option value="4">4</option><option value="5">5</option>';} if (${poptions_.$i} == "4"){echo '<option value="4">4</option><option value="5">5</option>';} if (${poptions_.$i} == "5"){echo '<option value="5">5</option>';} if (${poptions_.$i} == "(1)"){echo '<option value="1">1</option>';} echo '</select>'; } ?> </td> <td class="P5-price"> <div class="P-price-container"> <div>Our Price</div> <div class="P-price-container-subcontainer"> <div class="P-price-pound">£</div> <div class="P-price-value"> <?php if (${dynamic_prices_.$i} == "yes"){echo '<div class="dynamicprice"><div>';} elseif (${dynamic_prices_.$i} == "yes"){ echo $get[$i]['price'];} else echo $get[$i]['price']; ?> </div> </div> </div> </td> <?php // Dynamic prices opening or closing form field if (${dynamic_prices_.$i} == "no") { echo ''; } elseif (${dynamic_prices_.$i} == "yes") { echo ' <form method=POST action="/basket/basket.php"> <input type="hidden" name="type" value="single"> <input type="hidden" name="product_link" value="'.$url.'" /> <input type="hidden" name="return_url" value="'.${r_url_.$i}.'" /> '; } // fallback for older includes else { echo ''; } ?> <td class="P5-keynumber" style="display:<?php echo ${switch1_.$i}; echo ${switch_col_.$i}; ?>"> Key Number: <img class="fbTooltip" data-fb-tooltip="source:#tooltip1 attachToHost:true" src="/template_load/img/infox15.png"/><br /> <input name="product_key" type="text" class="BoxAreaFormat" id="quantity" value="N" size="3" maxlength="4" width="75" /> </td> <td class="P5-addtobasket" style="display:<?php echo ${switch1_.$i}; ?>"> <input type='hidden' name='product_id' value='<?php echo $get[$i]['product']; ?>' /> <input type='hidden' name='product_name' value='<?php echo $get[$i]['description']; ?>' /> <input type='hidden' name='product_cost' value='<?php echo $get[$i]['price']; ?>' /> <input type='hidden' name='product_thumb' value=/images/shop/<?php echo $get[$i]['product']; ?>.jpg' /> <input type='hidden' name='product_thumb_large' value='/images/large/<?php echo $get[$i]['product']; ?>.jpg' /> <input type='hidden' name='is_key' value='0' /> <?php if (${dynamic_prices_.$i} == "yes") { echo '<input type="hidden" name="product_quantity" value="1" />'; } elseif (${dynamic_prices_.$i} == "no") { echo '';} // fallback for older includes else {echo '';} ?> <input name="add_to_basket" type="image" src="template_load/img/addtobasket_new.png" alt="Click here to add items to your shopping basket" align="absmiddle"/> </td> <td class="P5-stock" style="display:<?php echo ${switch1_.$i}; ?>">In Stock</td> <td class="P-outofstock" colspan="3" style="display:<?php echo ${switch2_.$i}; ?>"> <p class="floatbox" data-fb-options="modal:false disableScroll:true width:500 scrolling:no enableDragResize:true cornerRadius:4 padding:12 colorTheme:black, contentBackgroundColor:#ffffe7"> This item is out of stock, <a href="#emailme-<?php echo $i; ?>" data-fb-options="caption:`Contact me when in Stock` boxLeft:+0% boxTop:100">Email me when in stock</a></p> </td> </form> </tr> </table> <!--</form> --> <?php $i++; ?> get_dynamic_prices.php <?php $productID = $_POST['productID']; include_once($_SERVER['DOCUMENT_ROOT'] ."/include/mysql_connect.php"); $result = mysql_query("SELECT * FROM products_prices WHERE product='".$productID."'") or die(mysql_error()); $row = mysql_fetch_array($result); echo $row['price']; mysql_close($connect); ?>
×
×
  • 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.