Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do i get my android application to send and receive data/information to the sqlserver
    primarykey
    data
    text
    <p>I am having difficulty getting my Android application to transmit the input it has received to myphpadmin server.</p> <p>I am wondering what do i need to add to my Andriod coding so that my application is able to get the php script to run and transmit the information to the server.</p> <p>What i have done so far is creating php scripts for configuration and connection purpose.</p> <pre><code>&lt;?php define('DB_USER', "root"); // db user define('DB_PASSWORD', "password"); // db password (mention your db password here) define('DB_DATABASE', "Wifi"); // database name define('DB_SERVER', "http://andy-009.dlink.net/"); // db server ?&gt; </code></pre> <p>and <pre><code>/** * A class file to connect to database */ class DB_CONNECT { // constructor function __construct() { // connecting to database $this-&gt;connect();} // destructor function __destruct() { // closing db connection $this-&gt;close();} /** * Function to connect with database */ function connect() { // import database connection variables require_once __DIR__ . '/db_config.php'; // Connecting to mysql database $con = mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD) or die(mysql_error()); // Selecing database $db = mysql_select_db(DB_DATABASE) or die(mysql_error()) or die(mysql_error()); // returing connection cursor return $con; } /** * Function to close db connection */ function close() { // closing db connection mysql_close(); } } </code></pre> <p>as well as a insertion php script</p> <pre><code>update_product.php &lt;?php /* * Following code will update a product information * A product is identified by product id (pid) */ // array for JSON response $response = array(); // check for required fields if (isset($_POST['WifiMacAddress']) &amp;&amp; isset($_POST['WifiSSID']) &amp;&amp; isset($_POST['WifiLatitude']) &amp;&amp; isset($_POST['WifiLongtitude']) &amp;&amp; isset($_POST['WifiLocation'])) { $WifiMacAddress = $_POST['WifiMacAddress']; $WifiSSID = $_POST['WifiSSID']; $WifiLatitude = $_POST['WifiLatitude']; $WifiLongtitude = $_POST['WifiLongtitude']; $WifiLocation = $_POST['WifiLocation']; // include db connect class require_once __DIR__ . '/db_connect.php'; // connecting to db $db = new DB_CONNECT(); // mysql update row with matched pid $result = mysql_query("UPDATE Wifi SET WifiSSID = '$WifiSSID', WifiLatitude = '$WifiLatitude', WifiLongtitude = '$WifiLongtitude' , WifiLocation = '$WifiLocation' WHERE WifiMacAddress = $WifiMacAddress"); // check if row inserted or not if ($result) { // successfully updated $response["success"] = 1; $response["message"] = "Product successfully updated."; // echoing JSON response echo json_encode($response); } else { } } else { // required field is missing $response["success"] = 0; $response["message"] = "Required field(s) is missing"; // echoing JSON response echo json_encode($response); } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload