Jump to content

finney2005

New Members
  • Posts

    5
  • Joined

  • Last visited

finney2005's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. thank you that seems to be i lot more usefull then what i had but still no error. the php recives the .json file which i can see on the sever but does not seem to convert it and put it in the table but does not show any errors. could this be aproblem on the webhost side as am using phpmyadmin. thanks agen
  2. sorry like i said i realy new to all this and am trying to teach myself along the way and realy appreciate all the help and advice i get. i have put the error reporting ant the top of my php and will do form now on. the errors reporting did point out my mistake about the db name. it does not report any other mistakes once changed and is still not wrighting to the table. i have changed: // construct SQL statement $sql="INSERT INTO godfathersorder(Pizza, STUFEDCRUST, MOREINFO, coldel, price, NAME, ADDRESS1, ADDRESS2, ADDRESSS3, POSTCODE1, POSTCODE2,PHONE)VALUES('$Pizza', '$STUFEDCRUST', '$MOREINFO', '$coldel', '$price', '$NAME', '$ADDRESS1', '$ADDRESS2', '$ADDRESS3', '$POSTCODE1', '$POSTCODE2', '$PHONE')"; to mysqli_query($link,"INSERT INTO $tableName(Pizza, STUFEDCRUST, MOREINFO, coldel, price, NAME, ADDRESS1, ADDRESS2, ADDRESSS3, POSTCODE1, POSTCODE2,PHONE)VALUES('$Pizza', '$STUFEDCRUST', '$MOREINFO', '$coldel', '$price', '$NAME', '$ADDRESS1', '$ADDRESS2', '$ADDRESS3', '$POSTCODE1', '$POSTCODE2', '$PHONE'"); its still not wrighting into the table but the code seems to run fine. thanks agen for you help
  3. can anyone please helpme understand why its not wrighting to the table? thanks agen
  4. sorry i have just started learning maybe am learning outdated code i would realy like to get this working having spent so much time onit before i look at updating it thanks for you advice
  5. // database connection strings. change these to your DB and Table names. $dbName = "a6474605_order"; $tableName = "godfathersorder"; // connect to the table mysql_select_db(a6474605_order)or die("cannot select DB"); if (!$link) { exit('Error: Could not connect to MySQL server!'); } // lets prepare some files to capture what is going on. $incomingJson = 'json.txt'; //$fullArray = 'fullArray.txt'; // needed if you enable the debugging secton below $sqlErrorLog = "sqlErrors.txt"; // initialize the string with a blank value $string = ""; // start SEND data if ($_SERVER['REQUEST_METHOD'] === 'POST') { //capture incoming data error_reporting(1); $sig = $_POST["sig"]; $jsondata = $_POST["params"]; // this line captures the sent data so you can figure out what you need to send back. file_put_contents($incomingJson,$jsondata); // this line tells the application that the data send was successful. echo '{"Status":"Success"}'; // convert JSON to an array $array = json_decode($jsondata, TRUE); /* // formats the array to view it easier $results = print_r($array,true); file_put_contents($fullArray,$results); */ //get the total number of objects in the array $arrlength = count($array['Children']['1']['Properties']); // set while loop index $i = 0; //loop through array node and get row values while ($i < $arrlength ) { // get row value $value = $array['Children']['1']['Properties'][$i]['Value']."\n"; // convert delimited string to an array $arrayPieces = explode("|", $value); // get array values. This section would have to be modified to capture each value you are interested in. $rowName = $arrayPieces(0); // this variable will be blank if you don't name your rows. $Pizza = $arrayPieces(1); $STUFEDCRUST = $arrayPieces(2); $MOREINFO = $arrayPieces(3); $coldel = $arrayPieces(4); $price = $arrayPieces(5); $NAME = $arrayPieces(6); $ADDRESS1 = $arrayPieces(7); $ADDRESS2 = $arrayPieces( ; $ADDRESS3 = $arrayPieces(9); $POSTCODE1 = $arrayPieces(10); $POSTCODE2 = $arrayPieces(11); $PHONE = $arrayPieces(12); mysqli_select_db("godfathersorder", $link) // construct SQL statement $sql="INSERT INTO godfathersorder(Pizza, STUFEDCRUST, MOREINFO, coldel, price, NAME, ADDRESS1, ADDRESS2, ADDRESSS3, POSTCODE1, POSTCODE2,PHONE)VALUES('$Pizza', '$STUFEDCRUST', '$MOREINFO', '$coldel', '$price', '$NAME', '$ADDRESS1', '$ADDRESS2', '$ADDRESS3', '$POSTCODE1', '$POSTCODE2', '$PHONE')"; // insert SQL statement $result=mysql_query($sql); // catch any errors if($result){ // if successful do nothing for now. } else { // if failure, write to custom log $sqlError = "Error writing to database\n"; file_put_contents($sqlErrorLog, $sqlError, FILE_APPEND); } $i++; } } // end of POST ?> please help the insert into table does not seem to work as there is nothing going into mysql tabe the code leaves a json.text file to show the first part working but does not seem to put the contents into my table. please please help godfathersSERVER.php
×
×
  • 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.