erasmusackon Member Licensed User Longtime User Jun 16, 2017 #1 This code is able to retrieve records from the server Code: $q = mysqli_query($con,"SELECT * FROM DepositTransactions"); $rows = array(); while($r = mysqli_fetch_assoc($q)) { $rows[] = $r; } echo json_encode($rows); mysqli_close($con); GetTransactions is unable to work. it returns [] when i checked the log. Am i doing anything wrong in this "GetTransactions" Code: Dim DownloanTransactions As HttpJob DownloanTransactions.Initialize("DownT", Me) DownloanTransactions.Download2(Server, Array As String ("action", "GetTransactions","memberID",MemberID,"lasttrans",LastTransID)) Code: $action = $_GET["action"]; switch ($action) { case "CountPersons": $q = mysqli_query($con,"SELECT * FROM DepositTransactions WHERE MemberID=40001762"); $count = mysqli_num_rows($q); print json_encode($count); mysqli_close($con); break; Case "GetTransactions": $memberid = $_GET["memberid"]; $lasttrans = $_GET["lasttrans"]; $q = mysqli_query($con,"SELECT * FROM DepositTransactions WHERE MemberID=$memberid AND TranNo>$lasttrans"); $rows = array(); while($r = mysqli_fetch_assoc($q)) { $rows[] = $r; } print json_encode($rows); mysqli_close($con); break; Last edited: Jun 16, 2017
This code is able to retrieve records from the server Code: $q = mysqli_query($con,"SELECT * FROM DepositTransactions"); $rows = array(); while($r = mysqli_fetch_assoc($q)) { $rows[] = $r; } echo json_encode($rows); mysqli_close($con); GetTransactions is unable to work. it returns [] when i checked the log. Am i doing anything wrong in this "GetTransactions" Code: Dim DownloanTransactions As HttpJob DownloanTransactions.Initialize("DownT", Me) DownloanTransactions.Download2(Server, Array As String ("action", "GetTransactions","memberID",MemberID,"lasttrans",LastTransID)) Code: $action = $_GET["action"]; switch ($action) { case "CountPersons": $q = mysqli_query($con,"SELECT * FROM DepositTransactions WHERE MemberID=40001762"); $count = mysqli_num_rows($q); print json_encode($count); mysqli_close($con); break; Case "GetTransactions": $memberid = $_GET["memberid"]; $lasttrans = $_GET["lasttrans"]; $q = mysqli_query($con,"SELECT * FROM DepositTransactions WHERE MemberID=$memberid AND TranNo>$lasttrans"); $rows = array(); while($r = mysqli_fetch_assoc($q)) { $rows[] = $r; } print json_encode($rows); mysqli_close($con); break;
R ronell Well-Known Member Licensed User Longtime User Jun 16, 2017 #2 try this.. Code: "SELECT * FROM 'DepositTransactions' WHERE MemberID= '$memberid' AND TranNo> '$lasttrans'" not tested Upvote 0
try this.. Code: "SELECT * FROM 'DepositTransactions' WHERE MemberID= '$memberid' AND TranNo> '$lasttrans'" not tested
erasmusackon Member Licensed User Longtime User Jun 16, 2017 #3 ronell said: try this.. Code: "SELECT * FROM 'DepositTransactions' WHERE MemberID= '$memberid' AND TranNo> '$lasttrans'" not tested Click to expand... Not working please Upvote 0
ronell said: try this.. Code: "SELECT * FROM 'DepositTransactions' WHERE MemberID= '$memberid' AND TranNo> '$lasttrans'" not tested Click to expand... Not working please
tigrot Well-Known Member Licensed User Longtime User Jun 16, 2017 #4 try: $q = mysqli_query($con,"SELECT * FROM DepositTransactions WHERE MemberID='$memberid' AND TranNo>'$lasttrans'"); Display $q to see if sql is well formed! ECHO $q Upvote 0
try: $q = mysqli_query($con,"SELECT * FROM DepositTransactions WHERE MemberID='$memberid' AND TranNo>'$lasttrans'"); Display $q to see if sql is well formed! ECHO $q
erasmusackon Member Licensed User Longtime User Jun 16, 2017 #5 tigrot said: try: $q = mysqli_query($con,"SELECT * FROM DepositTransactions WHERE MemberID='$memberid' AND TranNo>'$lasttrans'"); Display $q to see if sql is well formed! ECHO $q Click to expand... Thanks @tigrot. This is the error am getting from the error log <b>Parse error</b>: syntax error, unexpected '$rows' (T_VARIABLE), expecting ',' or ';' in <b>/home/sikasoft/public_html/app/newCon.php</b> on line <b>39</b><br /> Upvote 0
tigrot said: try: $q = mysqli_query($con,"SELECT * FROM DepositTransactions WHERE MemberID='$memberid' AND TranNo>'$lasttrans'"); Display $q to see if sql is well formed! ECHO $q Click to expand... Thanks @tigrot. This is the error am getting from the error log <b>Parse error</b>: syntax error, unexpected '$rows' (T_VARIABLE), expecting ',' or ';' in <b>/home/sikasoft/public_html/app/newCon.php</b> on line <b>39</b><br />
R ronell Well-Known Member Licensed User Longtime User Jun 16, 2017 #6 check the code before line 39 , you might miss a , or ; at the end of the line -- let us see php code again Upvote 0
check the code before line 39 , you might miss a , or ; at the end of the line -- let us see php code again
erasmusackon Member Licensed User Longtime User Jun 16, 2017 #7 I have modified the code and am now getting this "Response from server: []" Not getting the actual data. is there anything wrong with my code? Code: Dim DownloanTransactions As HttpJob DownloanTransactions.Initialize("DownT", Me) DownloanTransactions.Download2(Server, Array As String ("action", "GetTransactions","memberID",MemberID,"lasttrans",LastTransID)) Code: $action = $_GET["action"]; switch ($action) { Case "GetTransactions": $memberid = $_GET['memberid']; $lasttrans = $_GET['lasttrans']; $lasttrans= mysqli_real_escape_string($con, '$lasttrans'); $memberid = mysqli_real_escape_string($con, '$memberid'); $q = mysqli_query($con,"SELECT * FROM DepositTransactions WHERE MemberID='.$memberid.' AND TranNo>'.$lasttrans.'"); $rows = array(); while($r = mysqli_fetch_assoc($q)) { $rows[] = $r; } print json_encode($rows); mysqli_close($con); break; } Upvote 0
I have modified the code and am now getting this "Response from server: []" Not getting the actual data. is there anything wrong with my code? Code: Dim DownloanTransactions As HttpJob DownloanTransactions.Initialize("DownT", Me) DownloanTransactions.Download2(Server, Array As String ("action", "GetTransactions","memberID",MemberID,"lasttrans",LastTransID)) Code: $action = $_GET["action"]; switch ($action) { Case "GetTransactions": $memberid = $_GET['memberid']; $lasttrans = $_GET['lasttrans']; $lasttrans= mysqli_real_escape_string($con, '$lasttrans'); $memberid = mysqli_real_escape_string($con, '$memberid'); $q = mysqli_query($con,"SELECT * FROM DepositTransactions WHERE MemberID='.$memberid.' AND TranNo>'.$lasttrans.'"); $rows = array(); while($r = mysqli_fetch_assoc($q)) { $rows[] = $r; } print json_encode($rows); mysqli_close($con); break; }
tigrot Well-Known Member Licensed User Longtime User Jun 16, 2017 #8 why do you use square brackets in $rows? I think that you have to take them off Upvote 0
tigrot Well-Known Member Licensed User Longtime User Jun 16, 2017 #9 I read your code again. It looks like you want to move all rows fetched in $rows. If you do so, you will get only the last row fetched in $rows. Upvote 0
I read your code again. It looks like you want to move all rows fetched in $rows. If you do so, you will get only the last row fetched in $rows.
tigrot Well-Known Member Licensed User Longtime User Jun 16, 2017 #10 Put some echo here and there and simulate it from a browser... Upvote 0
R ronell Well-Known Member Licensed User Longtime User Jun 16, 2017 #11 tigrot said: why do you use square brackets in $rows? Click to expand... $row in an array containing the result .. Upvote 0
tigrot said: why do you use square brackets in $rows? Click to expand... $row in an array containing the result ..
tigrot Well-Known Member Licensed User Longtime User Jun 16, 2017 #12 Trace with ECHO statements and you will quicly get the issue! Upvote 0
tigrot Well-Known Member Licensed User Longtime User Jun 16, 2017 #13 ronell said: $row in an array containing the result .. Click to expand... Ahh Ok, out of order brain... Upvote 0
ronell said: $row in an array containing the result .. Click to expand... Ahh Ok, out of order brain...
R ronell Well-Known Member Licensed User Longtime User Jun 16, 2017 #14 post the whole updated php code, also the latest error .. Upvote 0
erasmusackon Member Licensed User Longtime User Jun 16, 2017 #15 ronell said: post the whole updated php code, also the latest error .. Click to expand... This code doesn't work but Code: $q = mysqli_query($con,"SELECT * FROM DepositTransactions WHERE MemberID= '$memberid' AND TranNo>'$lasttrans'"); This code works and return the results. what might be the problem? Code: $q = mysqli_query($con,"SELECT * FROM DepositTransactions WHERE MemberID= 40001762 AND TranNo>0"); Upvote 0
ronell said: post the whole updated php code, also the latest error .. Click to expand... This code doesn't work but Code: $q = mysqli_query($con,"SELECT * FROM DepositTransactions WHERE MemberID= '$memberid' AND TranNo>'$lasttrans'"); This code works and return the results. what might be the problem? Code: $q = mysqli_query($con,"SELECT * FROM DepositTransactions WHERE MemberID= 40001762 AND TranNo>0");
R ronell Well-Known Member Licensed User Longtime User Jun 16, 2017 #16 try working on the variable in the query.. that might be the problem Upvote 0
tigrot Well-Known Member Licensed User Longtime User Jun 16, 2017 #17 Is tranNo a number? In this case you need to omit ' ' before and after variable name Upvote 0
tigrot Well-Known Member Licensed User Longtime User Jun 16, 2017 #18 DISPLAY SQL text variable or you don't know what is the real SQL text! Upvote 0
R ronell Well-Known Member Licensed User Longtime User Jun 16, 2017 #19 learn basic php , read/watch tutorials .. the problem is just simple.. you were just lacking knowledge about the basic of PHP Upvote 0
learn basic php , read/watch tutorials .. the problem is just simple.. you were just lacking knowledge about the basic of PHP
erasmusackon Member Licensed User Longtime User Jun 16, 2017 #20 ronell said: learn basic php , read/watch tutorials .. the problem is just simple.. you were just lacking knowledge about the basic of PHP Click to expand... Learning for sure. But if you have the solution why not assist? Upvote 0
ronell said: learn basic php , read/watch tutorials .. the problem is just simple.. you were just lacking knowledge about the basic of PHP Click to expand... Learning for sure. But if you have the solution why not assist?