Advertisement
Guest User

Untitled

a guest
Mar 26th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.07 KB | None | 0 0
  1. Parse error: syntax error, unexpected 'mysqli_stmt_bind_param' (T_STRING) in C:xampphtdocsattendanceradio.php on line 19
  2.  
  3. <?php
  4.  
  5. $user = 'root';
  6. $pass = '';
  7. $db = 'testuser';
  8.  
  9. $con=mysqli_connect('localhost', $user, $pass, $db) or die('Unable to connect');
  10. mysql_select_db($testuser) or die(mysql_error());
  11.  
  12. $userid = $_POST['userid'];
  13. $eventid = $_POST['eventid'];
  14. $attending = $POST['attending'];
  15.  
  16. $statement = mysqli_prepare($con,
  17. 'INSERT INTO user_has_event(user_user_id, event_event_id, attendance)
  18. VALUES ($userid, $eventid, $attending)
  19. ON DUPLICATE KEY UPDATE attendance = $attending')
  20.  
  21. mysqli_stmt_bind_param($statement, 'iii', $userid, $eventid, $attending);
  22. mysqli_stmt_execute($statement);
  23.  
  24. mysqli_stmt_store_result($statement);
  25. mysqli_stmt_bind_result($statement, $userid, $eventid, $eventradio);
  26.  
  27. mysqli_stmt_close($statement);
  28.  
  29. mysqli_close($con);
  30. ?>
  31.  
  32. public class ServerRequests {
  33.  
  34. ProgressDialog progressDialog;
  35. public static final int CONNECTION_TIMEOUT = 1000 * 15;
  36. public static final String SERVER_ADDRESS = "http://10.0.2.2:80/";//Connects to the emulator
  37.  
  38. public ServerRequests(Context context) {
  39. progressDialog = new ProgressDialog(context);
  40. progressDialog.setCancelable(false);
  41. progressDialog.setTitle("Processing");
  42. progressDialog.setMessage("Please wait...");
  43. }
  44.  
  45. public void GetAttendanceDataAsyncTask(Attendance attendance, GetAttendanceCallback attendanceCallBack) {
  46. progressDialog.show();
  47. new getAttendanceDataAsyncTask(attendance, attendanceCallBack).execute();
  48. }
  49. public class getAttendanceDataAsyncTask extends AsyncTask<Void, Void, Void> {
  50. Attendance attendance;
  51. GetAttendanceCallback attendanceCallBack;
  52.  
  53. public getAttendanceDataAsyncTask(Attendance attendance, GetAttendanceCallback attendanceCallBack) {
  54. this.attendance = attendance;
  55. this.attendanceCallBack = attendanceCallBack;
  56. }
  57.  
  58. @Override
  59. protected Void doInBackground(Void... params) {
  60. Map<String, String> dataToSend = new HashMap<>();
  61. dataToSend.put("userid", MainActivity.getUserID() + "");
  62. dataToSend.put("eventid", EventPage.getEventID() + "");
  63. dataToSend.put("attending", EventPage.getRadio() + "");
  64.  
  65. String encodedStr = StrEncoder.getEncodedData(dataToSend);
  66.  
  67. BufferedReader reader = null;
  68.  
  69. try {
  70. URL url = new URL(SERVER_ADDRESS + "/attendanceradio.php");
  71.  
  72. HttpURLConnection con = (HttpURLConnection) url.openConnection(); //Opens attendanceradio.php
  73.  
  74. con.setConnectTimeout(CONNECTION_TIMEOUT); //Setting timeouts
  75. con.setReadTimeout(CONNECTION_TIMEOUT);
  76.  
  77. con.setRequestMethod("POST"); //Request post
  78.  
  79. con.setDoOutput(true);
  80. OutputStreamWriter writer = new OutputStreamWriter(con.getOutputStream());
  81.  
  82. writer.write(encodedStr);
  83. writer.flush();
  84.  
  85.  
  86. StringBuilder sb = new StringBuilder();
  87. reader = new BufferedReader(new InputStreamReader(con.getInputStream()));
  88.  
  89. String line;
  90. while ((line = reader.readLine()) != null) { //Read until there is something available
  91. sb.append(line + "n"); //Read and save line by line
  92. }
  93. line = sb.toString(); //Saving complete data received in string
  94.  
  95. //Check values received in Logcat
  96. Log.i("custom_check", "The values received in the store part are as follows:");
  97. Log.i("custom_check", line);
  98.  
  99. } catch (Exception e) {
  100. e.printStackTrace();
  101. } finally {
  102. if (reader != null) {
  103. try {
  104. reader.close(); //Closing the
  105. } catch (IOException e) {
  106. e.printStackTrace();
  107. }
  108. }
  109. }
  110. return null;
  111. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement