0

my android code sends variable to PHP file which supposed to use it in making queries on MYSQL Server.

the problem is after defining the variable, any command I write generates error.

the php code:

<?php
require "init.php";
$coresite = $_POST["selectedcoresite"]
?>

here I have no issue and the output of the file is "nothing" but working.

but if I added any thing like:

$coresite = $_POST["selectedcoresite"]
$x = "10";
?>

it return an error: Parse error: sytax error, unexpected'$x' (T_variable)

I tried with other commands like echo and print_r to the variable, still producing the same error with different variables.

is there anything missing here after receiving my data from android?

I should complete the php code with prepared statement to be like below but definitely it is producing the same error:

<?php
require "init.php";
$coresite = $_POST["selectedcoresite"]
$stmt = $mysqli -> prepare("SELECT Cabinet_Row FROM cabinets WHERE Core_Site=?");
$stmt -> bind_param("s",$coresite);
$stmt -> execute();
$stmt -> bind_result($result);
$stmt -> fetch();
?>
  • 1
    `$coresite = $_POST["selectedcoresite"]` is that missing semi-colon in your real code or not? If not; add it. Personally, I think it isn't. Closing this one. – Funk Forty Niner May 01 '16 at 14:48
  • if you are sending data to the PHP file, you should uses GET instead of POST aka $_GET["selectedcoresite"] – Andy the android May 01 '16 at 14:50
  • no the ; was missing here only, I am using httpURLConnection.setRequestMethod("POST"); in the android app, what then should be in the PHP variable? POST or GET? many thanks – Sheriff Said Elahl May 01 '16 at 15:02
  • It worked with POST successfully :) thanks for your support, I had another errors in the rest of PHP code I will try to figure it out. thanks again – Sheriff Said Elahl May 01 '16 at 15:28

0 Answers0