Jump to content

budimir

Members
  • Posts

    522
  • Joined

  • Last visited

Everything posted by budimir

  1. Thank you for the help. I found a problem. Thank you very much.
  2. Hey Guru, Thanks for you're suggestion. This is error I get: Fatal error: Uncaught exception 'mysqli_sql_exception' with message 'Commands out of sync; you can't run this command now' in C:\wamp\www\pma\calculation\custom_based_method.php on line 159 What does that mean and how to trace it?
  3. Can someone explain why prepared statement in example below is failing while mysqli_query is working without any problem with exactly same set of data? I tried everything I could figure out and can't see the reason why it is happening. //Now we get costs in% and absolute $number = 0; $numberText = ""; $numberName = ""; $total_costs = 0; $total_costs_abs = 0; foreach($cost_array as $key => $value){ //Here we select only costs with % so we could calculate percentage if(strcmp($value["cost_measure"],"Percent") === 0){ //$number .= getPercentOfNumber($local,$value["cost_amount"])."<br>"; $number = getPercentOfNumber($local,$value["cost_amount"]); //$numberText.= $value["cost_amount"]." %<br>"; $numberText = $value["cost_amount"]; //$numberName .= "cost_name ".$value["cost_name"]."<br>"; $numberName = $value["cost_name"]; //Total value of all percentage costs $total_costs += $number; //Insert calculated costs in DB //Not working if ($stmt = $conn_mysqli -> prepare("INSERT INTO calculations_cost (calculation_id, costs_id, user_id, cost_time, original_number, cost_amount, cost_measure, calculated_cost, cost_name) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)")) { $stmt -> bind_param("iiissssss", $calculation_id, $costs_id, $user_id, $create_time, $local, $numberText, $measure, $number, $numberName); $stmt -> execute(); $stmt -> close(); } //Working $sql = "INSERT INTO calculations_cost (calculation_id, costs_id, user_id, cost_time, original_number, cost_amount, cost_measure, calculated_cost, cost_name) VALUES ('$calculation_id', '$costs_id', '$user_id', '$create_time', '$local', '$numberText', '".$value['cost_measure']."', '$number', '$numberName')"; mysqli_query($mysqli,$sql) or die (mysqli_error($mysqli)); echo $sql."<br>"; //echo "Total costs: $total_costs<br>"; } }
  4. Thank you Psycho! You're code helped me to find my problem and get the value.
  5. I have tried that, but I can't get the value of select box.
  6. Hi, I have a radio button which, when clicked, is opening select. I would like to store the value of a radio and select into two separate cookies. This is my code I'm using, but I can't get second on change event to fire and get the value of select. I do get value of radio and store in cookie, but when trying to get value from select I get null. Can you, please help me and tell me what I'm doing wrong? Html code: <div class="row"> <div class="col-md-6"> <div class="radio clip-radio radio-primary"> <input type="radio" id="radio3" name="vertical" value="Pricelist" /> <label for="radio3"> Pricelist </label> </div> <div id="Pricelist" class="desc"> <div class="form-group"> <select class="cs-select cs-skin-elastic" name="pricelist" id="pricelist_select"> <option value="" disabled selected>Select pricelist</option> <option value="1">1</option> <option value="2">2</option> </select> </div> </div> jQuery //Displaying select box when type radio button is clicked $(document).ready(function() { $("input[name=vertical]").on( "change", function() { var test = $(this).val(); $(".desc").hide(); $("#"+test).show(); $("#pricelist_select").val(); $('#pricelist_select').trigger("change"); alert($("#pricelist_select").find(":selected").val()); $.cookie('pricelist_select', $("#pricelist_select").val()); } ); }); CSS .desc { display: none; }
  7. For some reason I can't get it to work. Could you give me an example how to get cookie value and display it to see the value?
  8. I'm using PHP to view cookie value, but obivously it's not working properly. <?php echo "$COOKIE['calc']"; ?> What javascript code would be to see cookie value in real time (without refreshing page)?
  9. Oh, OK. Now I can see that cookie immediatly gets new value, but the page is not displaying it when I go to second step. What do I need to do to get the value at the same moment when I get to second step?
  10. Yes, I can see it. It is created. It doesn't say any time when is created, but I can see it is created when radio is selected.
  11. Yes, I can see value which is displaying. For example I select Cost and click to go to second step and there I can see it's displaying Cost, but when I go back to first step and select Customer and again go to second step the value didn't change from Cost. Strange thing is that I need to hit F5 and refresh browser exactly two times for new selection to work. I mean I hit F5 twice then make a new selection go to step two and I can see my new selection. Same thing is hapening all the time? Do you have any idea why I need to refresh two times so I could get my new value?
  12. Hi everyone, I'm strugling with javascript and updating cookie value, so I would like to ask for some help. I'm using bootstrap wizard and offer user some options to select. I would like to store that choice into cookie, but the problem I'm runing into is when user clicks on Cost and clicks Next on second step and then he decides to go back and make antoher choice and he chooses Custom, cookie is not updated with new value. I have to refresh page for couple of times before cookie changes it's value. Below is my code I'm using to update and remove cookie so please help me and clarify me why cookie is not updated without refreshing screen for couple of times??? <script type='text/javascript'> $('input:radio').on('change', function() { if ($(this).val() === "Cost") { $.cookie('calc', 'Cost') } else { $.removeCookie('calc', { path: '/' }); } if ($(this).val() === "Competition") { $.cookie('calc', 'Competition') } else { $.removeCookie('calc', { path: '/' }); } if ($(this).val() === "Customer") { $.cookie('calc', 'Customer') } else { $.removeCookie('calc', { path: '/' }); } if ($(this).val() === "Custom") { $.cookie('calc', 'Custom') } else { $.removeCookie('calc', { path: '/' }); } }); </script>
  13. Ok, I managed to figure out that this part of code is blocking it: CKEDITOR.instances."editor2".on('blur', function(){CKEDITOR.instances."editor2".updateElement();}); It is used for updating textarea on input and before submiting form. Why is it blocking validation?
  14. I need you're help with jquery form validation. I have been using jguery form validation but when I have included ckeditor on the page validation stopped working. I can't figure out why. I'm not very good with javascript so it's hard for me to figure out what is blocking it. Html form I'm using is: <form action="save_costs.php" method="POST" role="form" id="form2"> <div class="row"> <div class="col-md-12"> <div class="errorHandler alert alert-danger no-display"> <i class="fa fa-times-sign"></i> You have some form errors. Please check below. </div> <div class="successHandler alert alert-success no-display"> <i class="fa fa-ok"></i> Your form validation is successful! </div> </div> <div class="col-md-6"> <div class="form-group"> <label class="control-label"> <?php if ($_SESSION['language'] == "English") { echo "Name"; } else if ($_SESSION['language'] == "Croatian") { echo "Naziv"; } ?> <span class="symbol required"></span> </label> <input type="text" placeholder="Insert name" class="form-control" id="name" name="name" /> </div> <div class="form-group"> <label class="control-label"> <?php if ($_SESSION['language'] == "English") { echo "Description"; } else if ($_SESSION['language'] == "Croatian") { echo "Opis"; } ?> <span class="symbol required"></span> </label> <input type="text" placeholder="Insert description" class="form-control" id="description" name="description" /> </div> </div> <div class="col-md-6"> <div class="row"> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label class="control-label"> <?php if ($_SESSION['language'] == "English") { echo "Comments"; } else if ($_SESSION['language'] == "Croatian") { echo "Komentari"; } ?> </label> <textarea class="ckeditor form-control" id="editor2" name="comment" cols="10" rows="10"></textarea> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div> <span class="symbol required"></span><?php if ($_SESSION['language'] == "English") { echo "Required Fields"; } else if ($_SESSION['language'] == "Croatian") { echo "Obavezna polja"; } ?> <hr /> </div> </div> </div> <div class="row"> <div class="col-md-8"> </div> <div class="col-md-4"> <button class="btn btn-primary btn-wide pull-right" type="submit"> <?php if ($_SESSION['language'] == "English") { echo "Submit"; } else if ($_SESSION['language'] == "Croatian") { echo "Spremi"; } ?> <i class="fa fa-arrow-circle-right"></i> </button> </div> </div> </form> Javascript file is attached. This is how I initalise form validation and CKeditor. <script src="../vendor/jquery/jquery.min.js"></script> <script src="../vendor/jquery-validation/jquery.validate.min.js"></script> <script src="../vendor/ckeditor/ckeditor.js"></script> <script src="../vendor/ckeditor/adapters/jquery.js"></script> <script src="../items/js/article_validation.js"></script> <script> <script> jQuery(document).ready(function() { Main.init(); FormValidator.init(); CKEDITOR.instances."editor2".on('blur', function(){CKEDITOR.instances."editor2".updateElement();}); }); </script> Can you, please, help me? I tried everything I thought it could block it. I don't know what to do anymore.
  15. Hey people I need some help with form validation. I have done validation, but for some reason it takes a long time to process a form and then run script to store data in DB. I have check and traced problem to javascript that I'm using (it's not PHP that is causing the problem). I can't understand what is taking it to load so long. At one point my browser goes to Not responding and then after a minute it process a form. This is how I validate user input: <form action="save_article.php" method="POST" role="form" id="form2"> <div class="row"> <div class="col-md-12"> <div class="errorHandler alert alert-danger no-display"> <i class="fa fa-times-sign"></i> You have some form errors. Please check below. </div> <div class="successHandler alert alert-success no-display"> <i class="fa fa-ok"></i> Your form validation is successful! </div> </div> <div class="col-md-6"> <div class="form-group"> <label class="control-label"> SKU <span class="symbol required"></span> </label> <input type="text" placeholder="Insert SKU" class="form-control" id="sku" name="sku" /> </div> <div class="form-group"> <label class="control-label"> Last Name <span class="symbol required"></span> </label> <input type="text" placeholder="Insert your Last Name" class="form-control" id="lastname2" name="lastname2"> </div> And javascript validation is: var FormValidator = function () { "use strict"; var validateCheckRadio = function (val) { $("input[type='radio'], input[type='checkbox']").on('ifChecked', function(event) { $(this).parent().closest(".has-error").removeClass("has-error").addClass("has-success").find(".help-block").hide().end().find('.symbol').addClass('ok'); }); }; // function to initiate Validation Sample 1 var runValidator1 = function () { var form1 = $('#form'); var errorHandler1 = $('.errorHandler', form1); var successHandler1 = $('.successHandler', form1); $.validator.addMethod("FullDate", function () { //if all values are selected if ($("#dd").val() != "" && $("#mm").val() != "" && $("#yyyy").val() != "") { return true; } else { return false; } }, 'Please select a day, month, and year'); $('#form').validate({ errorElement: "span", // contain the error msg in a span tag errorClass: 'help-block', errorPlacement: function (error, element) { // render error placement for each input type if (element.attr("type") == "radio" || element.attr("type") == "checkbox") { // for chosen elements, need to insert the error after the chosen container error.insertAfter($(element).closest('.form-group').children('div').children().last()); } else if (element.attr("name") == "dd" || element.attr("name") == "mm" || element.attr("name") == "yyyy") { error.insertAfter($(element).closest('.form-group').children('div')); } else { error.insertAfter(element); // for other inputs, just perform default behavior } }, ignore: "", rules: { firstname: { minlength: 2, required: true }, lastname: { minlength: 2, required: true }, email: { required: true, email: true }, password: { minlength: 6, required: true }, password_again: { required: true, minlength: 5, equalTo: "#password" }, yyyy: "FullDate", gender: { required: true }, zipcode: { required: true, number: true, minlength: 5 }, city: { required: true }, newsletter: { required: true } }, messages: { firstname: "Please specify your first name", lastname: "Please specify your last name", email: { required: "We need your email address to contact you", email: "Your email address must be in the format of name@domain.com" }, gender: "Please check a gender!" }, groups: { DateofBirth: "dd mm yyyy", }, invalidHandler: function (event, validator) { //display error alert on form submit successHandler1.hide(); errorHandler1.show(); }, highlight: function (element) { $(element).closest('.help-block').removeClass('valid'); // display OK icon $(element).closest('.form-group').removeClass('has-success').addClass('has-error').find('.symbol').removeClass('ok').addClass('required'); // add the Bootstrap error class to the control group }, unhighlight: function (element) { // revert the change done by hightlight $(element).closest('.form-group').removeClass('has-error'); // set error class to the control group }, success: function (label, element) { label.addClass('help-block valid'); // mark the current input as valid and display OK icon $(element).closest('.form-group').removeClass('has-error').addClass('has-success').find('.symbol').removeClass('required').addClass('ok'); }, submitHandler: function (form) { successHandler1.show(); errorHandler1.hide(); // submit form //$('#form').submit(); } }); }; // function to initiate Validation Sample 2 var runValidator2 = function () { var form2 = $('#form2'); var errorHandler2 = $('.errorHandler', form2); var successHandler2 = $('.successHandler', form2); $.validator.addMethod("getEditorValue", function () { $("#editor1").val($('#form2 .summernote').code()); if ($("#editor1").val() != "" && $("#editor1").val().replace(/(<([^>]+)>)/ig, "") != "") { $('#editor1').val(''); return true; } else { return false; } }, 'This field is required.'); form2.validate({ errorElement: "span", // contain the error msg in a small tag errorClass: 'help-block', errorPlacement: function (error, element) { // render error placement for each input type if (element.attr("type") == "radio" || element.attr("type") == "checkbox") { // for chosen elements, need to insert the error after the chosen container error.insertAfter($(element).closest('.form-group').children('div').children().last()); } else if (element.hasClass("ckeditor")) { error.appendTo($(element).closest('.form-group')); } else { error.insertAfter(element); // for other inputs, just perform default behavior } }, ignore: "", rules: { sku: { minlength: 2, required: true }, lastname2: { minlength: 2, required: true }, email2: { required: true, email: true }, occupation: { required: true }, dropdown: { required: true }, services: { required: true, minlength: 2 }, creditcard: { required: true, creditcard: true }, url: { required: true, url: true }, zipcode2: { required: true, number: true, minlength: 5 }, city2: { required: true }, editor1: "getEditorValue", editor2: { required: true } }, messages: { firstname: "Please specify your first name", lastname: "Please specify your last name", email: { required: "We need your email address to contact you", email: "Your email address must be in the format of name@domain.com" }, services: { minlength: jQuery.validator.format("Please select at least {0} types of Service") } }, invalidHandler: function (event, validator) { //display error alert on form submit successHandler2.hide(); errorHandler2.show(); }, highlight: function (element) { $(element).closest('.help-block').removeClass('valid'); // display OK icon $(element).closest('.form-group').removeClass('has-success').addClass('has-error').find('.symbol').removeClass('ok').addClass('required'); // add the Bootstrap error class to the control group }, unhighlight: function (element) { // revert the change done by hightlight $(element).closest('.form-group').removeClass('has-error'); // set error class to the control group }, success: function (label, element) { label.addClass('help-block valid'); // mark the current input as valid and display OK icon $(element).closest('.form-group').removeClass('has-error').addClass('has-success').find('.symbol').removeClass('required').addClass('ok'); }, submitHandler: function (form) { successHandler2.show(); errorHandler2.hide(); // submit form $('#form2').submit(); } }); CKEDITOR.disableAutoInline = true; $('textarea.ckeditor').ckeditor(); }; return { //main function to initiate template pages init: function () { validateCheckRadio(); runValidator1(); runValidator2(); } }; }();
  16. Found a problem. It was nulls allowed and it should be 0 in all records.
  17. iznos_fakture (DECIMAL (10,2)) is amount of invoice to be payed iznos_placanja (DECIMAL (10,2)) is amount payed for that invoice MONTH(datum_placanja) is month when that invoice is due I would like to find all invoices in december that are not yet payed. I see in table that there are two invoices not payed. For some reason I can't display them. No errors. I'm getting empty result.
  18. Guys how can I make this query work SELECT SUM(iznos_fakture) as ukupno FROM fakture_placanja WHERE iznos_placanja != iznos_fakture AND MONTH(datum_dospijeca) = '12' I need to find where iznos_placanja is different from iznos_fakture. They are two columns in same DB? Any ideas?
  19. Barand, As always first on my posts and most willing to help. Thanks for you're reply Barand! I have managed to figure out my problem while I was waiting for help. You are right, my rows are getting duplicate because of joins, so I have reworked the query and now it's working and it looks like this. SELECT ABS(SUM(quantity)) as zbroj, a.kataloski_broj, a.id, a.entry_type_desc, a.posting_date, a.item_category, a.product_group FROM prodaja_zaliha a LEFT JOIN (SELECT kataloski_broj, nabavna_cijena, neto_VPC, preporucena_VPC FROM kalkulacija_stavke GROUP BY kataloski_broj) AS b ON a.kataloski_broj = b.kataloski_broj LEFT JOIN (SELECT kataloski_broj, nabavna_cijena, VPC FROM kalkulacija_stavke_rabat GROUP BY kataloski_broj) AS c ON a.kataloski_broj = c.kataloski_broj LEFT JOIN(SELECT kataloski_broj_NAV, VPC, PVPC FROM katalog_pribora_item GROUP BY kataloski_broj_NAV) AS d ON a.kataloski_broj = d.kataloski_broj_NAV WHERE a.kataloski_broj = 'M1200' AND a.entry_type_desc = 'Prodaja' AND YEAR(a.posting_date) = '2015' I need to style it a bit, but it's finally giving correct result. Barand, thank you for reply!
  20. Hi people, I'm having a problem with my SQL query which is not doing what I would like. I have this query: SELECT a. id, a.kataloski_broj, SUM(a.quantity) AS zbroj, entry_type_desc, posting_date, item_category, product_group, b.nabavna_cijena as neto_nabavna, b.neto_VPC, b.preporucena_VPC, c.nabavna_cijena as rabat_nabavna, c.VPC, d.VPC as NAV_VPC, d.PVPC as NAV_PVPC FROM prodaja_zaliha a LEFT JOIN kalkulacija_stavke b ON a.kataloski_broj = b.kataloski_broj LEFT JOIN kalkulacija_stavke_rabat c ON a.kataloski_broj = c.kataloski_broj LEFT JOIN katalog_pribora_item d ON a.kataloski_broj = d.kataloski_broj_NAV WHERE a.entry_type_desc = 'Prodaja' AND YEAR(a.posting_date) = '2015' AND a.kataloski_broj = 'M1200' GROUP BY a.id ASC The problem is that it returns SUM(a.quantity) AS zbroj in 1432 quantity, while there is actually 182 quantity in DB. What am I doing wrong?
  21. Couple of things. 1. While you are learning, try to learn correct way. Mysql is depreciated so you need to use mysqli! You will need to rewrite you're code at one point so it's easier to do it right now. 2. Where is you're checkbox that you want? 3. You will need to implement form 4. You will need onclick event to do what you want (javascript). There are other solutions you can do it. 5. Build you're code the way you want it, tell us what is the error or problem and we will help you out. Hope this put's you on the right track.
  22. Can you show you're code in include("kf_open_order_status.php");?
  23. Three questions: 1) Is mail really sent to the person? 2) What do you get when you echo $text variable? 3) Did you jsut copy/paste that script or you know what you're variables are ($host variable?)?
×
×
  • 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.