Nahitaji msaada- Web Service - Json & PhP & Postman

herman3

JF-Expert Member
Feb 7, 2015
509
659
Habarini wadau,

Nahitaji kutuma data kwenye server kwa kutumia mobile app kwa njia ya web service, hizo data zitabeba iterm name na price then id inakuwa auto increment, nimetengeneza db kwenye phpMyadmin na kwenye root directory nimeweka hizi code

PHP:
<?php

// Create connection
$con=mysqli_connect("localhost","wametsy-auest","wamhags_shst","waayuu_990t");

// Check connection
if (mysqli_connect_errno())
{
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

// Select all of our stocks from table 'stock_tracker'
$sql = "SELECT * FROM stock_tracker";

// Confirm  results
if ($result = mysqli_query($con, $sql))
{
    // create an array to hold the results
        // and an array to hold the data
    $resultArray = array();
    $tempArray = array();

    // Loop through each result
    while($row = $result->fetch_object())
    {
        // Add each result into the results array
        $tempArray = $row;
        array_push($resultArray, $tempArray);
    }

    // Encode the array to JSON and output the results
    echo json_encode($resultArray);
}

// Close connections
mysqli_close($con);
?>

ila kila nikijaribu kutuma data kwenye server iwe kwa kutumia postman au android app haionyeshi any error message postman inaonyesha status 200 ok success lakini nikienda kwenye DB hakuna data ambayo inakuwa imeingia, nipo mbele yenu nisaidieni.
 
Habarini wadau,

Nahitaji kutuma data kwenye server kwa kutumia mobile app kwa njia ya web service, hizo data zitabeba iterm name na price then id inakuwa auto increment, nimetengeneza db kwenye phpMyadmin na kwenye root directory nimeweka hizi code

PHP:
<?php

// Create connection
$con=mysqli_connect("localhost","wametsy-auest","wamhags_shst","waayuu_990t");

// Check connection
if (mysqli_connect_errno())
{
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

// Select all of our stocks from table 'stock_tracker'
$sql = "SELECT * FROM stock_tracker";

// Confirm  results
if ($result = mysqli_query($con, $sql))
{
    // create an array to hold the results
        // and an array to hold the data
    $resultArray = array();
    $tempArray = array();

    // Loop through each result
    while($row = $result->fetch_object())
    {
        // Add each result into the results array
        $tempArray = $row;
        array_push($resultArray, $tempArray);
    }

    // Encode the array to JSON and output the results
    echo json_encode($resultArray);
}

// Close connections
mysqli_close($con);
?>

ila kila nikijaribu kutuma data kwenye server iwe kwa kutumia postman au android app haionyeshi any error message postman inaonyesha status 200 ok success lakini nikienda kwenye DB hakuna data ambayo inakuwa imeingia, nipo mbele yenu nisaidieni.
Swala la Kupata success response message halimaanishi kuwa data zimetumwa kwenye db.
Kwa muktadha wa postman lazima uangalie na kuzingatia method unayotumia kwenye form, na inatakiwa kuwa sawa na ile itakayotumika kule postman.
Haukuonyesha structure ya table yako tuone maana huenda kuna shida humo pia haukuonyesha parameter zinazotumika kwenye form ambayo page yake ndo unalink postman.
Haukuonyesha script inayopelekea data kwenye db ikoje
Umeonyesha script inayofetch data kutoka kwenye db na ndo maana inaonyesha nothing kwa kuwa table ni empty.

CHA KUFANYA
Onyesha table yako kikamilifu.
Onyesha script inayopelekea data maana inaweza kuwa ni kizuizi pia.
Onyesha snap za postman.
 
Habarini wadau,

Nahitaji kutuma data kwenye server kwa kutumia mobile app kwa njia ya web service, hizo data zitabeba iterm name na price then id inakuwa auto increment, nimetengeneza db kwenye phpMyadmin na kwenye root directory nimeweka hizi code

PHP:
// Create connection
$con=mysqli_connect("localhost","wametsy-auest","wamhags_shst","waayuu_990t");

// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

// Select all of our stocks from table 'stock_tracker'
$sql = "SELECT * FROM stock_tracker";

// Confirm results
if ($result = mysqli_query($con, $sql))
{
// create an array to hold the results
// and an array to hold the data
$resultArray = array();
$tempArray = array();

// Loop through each result
while($row = $result->fetch_object())
{
// Add each result into the results array
$tempArray = $row;
array_push($resultArray, $tempArray);
}

// Encode the array to JSON and output the results
echo json_encode($resultArray);
}

// Close connections
mysqli_close($con);
?>

ila kila nikijaribu kutuma data kwenye server iwe kwa kutumia postman au android app haionyeshi any error message postman inaonyesha status 200 ok success lakini nikienda kwenye DB hakuna data ambayo inakuwa imeingia, nipo mbele yenu nisaidieni.

Hiyo simu iko kwenye network moja na server ya pc? Kama ni kwenye Android app to pc server unaweza kutumia volley library it is very simple and if kama kuna error lazima itakuambia,but all in all nakushauri utumie stackoverflow kutatua matatizo yako ya code


Sent using Jamii Forums mobile app
 
Back
Top Bottom