Wednesday 15 February 2012

PHP / JSON issues -



PHP / JSON issues -

i having unusual issues php / json worked fine till yesterday, havent changed in coding.

let me explain whole situation. created order processing scheme json beingness used fetching info , updating right away display. 1 of features are, search client if not client business relationship found, create new 1 , utilize in order right away.

till yesterday worked without issues, if no client business relationship found screen open , info filled in, , business relationship saved.

it uses json check if client business relationship exists. user returned main screen business relationship # filled press come in fill in name, address, phone etc (json used well).

now json doesnt find information, though checking database , client business relationship saved. open straight json file in order see if there issues when update of database done, shows null.

when refresh page, finds appropriate information.

here code used encode json

class="lang-php prettyprint-override">$stud_id = $_get["id"]; $qr = "select * customers business relationship = '$stud_id';"; $res= mysql_query($qr); $row = mysql_fetch_array($res); $stud_arr["customer_name"] = $row["name"]; $stud_arr["customer_address"] = $row["address"]; $stud_arr["customer_city"] = $row["city"]; $stud_arr["customer_state"] = $row["state"]; $stud_arr["customer_zipcode"] = $row["zipcode"]; $stud_arr["customer_phone"] = $row["phone"]; $stud_arr["customer_email"] = $row["email"]; $stud_arr["terms"] = $row["terms"]; header('content-type: application/json;'); echo json_encode($stud_arr);

here function uses code:

class="snippet-code-js lang-js prettyprint-override">var id_val = m; var url = "json.php?id=" + id_val + "&act=sales"; $("#customer_account").attr("disabled", "disabled"); $("#ajaxloader").show(); $.getjson(url, function(json) { $.each(json, function(k, v) { document.getelementbyid(k).value = v; }); $("#ajaxloader").hide(); if (isobjectempty(json)) { alert("no client found, please come in client account, or search customer") var reply = confirm("do want create new account?", "yes", "no"); document.getelementbyid('customer_account').disabled = false; document.getelementbyid('customer_account').focus(); if (answer == true) { window.open('addnewcustomer.php?account=' + document.getelementbyid('customer_account').value).focus(); } } else { var url4 = "getallshipto.php?id=" + document.getelementbyid('customer_account').value; var countertemp = 1; document.getelementbyid('ship_to').options[0] = new option("select ship to", ''); $.getjson(url4, function(json) { $.each(json, function(k, v) { document.getelementbyid('ship_to').options[countertemp] = new option(v, k); document.getelementbyid('ship_to').options[countertemp].id = countertemp; countertemp++; }); }); document.getelementbyid('customer_account').disabled = true; document.getelementbyid('searchcustomer1').onclick = ""; document.getelementbyid('division').focus(); } });

so when first open order entry screen, triggered

window.open('addnewcustomer.php?account=' + document.getelementbyid('customer_account').value).focus();

then when client business relationship entered, , know saved, 1 time again same triggered

window.open('addnewcustomer.php?account=' + document.getelementbyid('customer_account').value).focus();

but if open json.php necessary info in address bar, first shows null show right values, see bellow.

{"customer_name":"null","customer_address":"null","customer_city":"null","customer_state":"null","customer_zipcode":"null","customer_phone":"null","customer_email":"null","terms":"null"}

after refresh:

{"customer_name":"te","customer_address":"te","customer_city":"te","customer_state":"te","customer_zipcode":"te","customer_phone":"te","customer_email":"","terms":"cod"}

so realy dont know going on, , how solve issue.

any help appreciate it, give thanks you.

php json

No comments:

Post a Comment