Php from android in json not posting to table, is there something wrong in my code? -
i have android app converting info json , sending php/mysql, response on phone fine nothing getting table, i'm not experienced in php, did screw code?
<?php include('../htconfig/dbconfig.php'); $dbsuccess = false; $dbconnected = mysql_connect($db['hostname'],$db['username'],$db['password']); if ($dbconnected) { $dbselected = mysql_select_db($db['database'],$dbconnected); if ($dbselected) { $dbsuccess = true; } } $data_back = json_decode(file_get_contents('php://input')); $username = $data_back->{"user"}; $password = $data_back->{"pword"}; $purchasedfrom = $data_back->{"pfrom"}; $vin = $data_back->{"vin"}; $color = $data_back->{"color"}; $makeindex = $data_back->{"make"}; $modelindex= $data_back->{"model"}; $year = $data_back->{"year"}; $bid = $data_back->{"bid"}; $inv = $data_back->{"purchaseprice"}; $bidcontact = $data_back->{"contact"}; $bidemail= $data_back->{"email"}; mysql_query("insert tblinventory (vin, makeindex, modelindex, year, color,bid,inv, bidcontact, bidemail, purchasedfrom) values ('$vin','$makeindex', '$modelindex', '$year', '$color', '$bid', '$inv', '$bidcontact', '$bidemail', '$purchasedfrom')"); $responses = array(); { $responses[] = array( $vin . " " . $makeindex . " " . $modelindex." ". $year." " ); } header("content-type: application/json"); echo json_encode($responses); ?>
needed add error checking code , make sure there actual database connection. make sure input , query have same name..see purchasedfrom , pfrom. guys , links, lot. happy coding :)
Comments
Post a Comment