Hello,
I have been working on a project that integrate corona with php and mysql.
I need to both post information and get information to and from the database.
For some reason I encounter a very weird problems, here they are:
When calling for network request with _POST I can pass params as table so I can update the database normally. When I replace the _POST with _GET I get an error where my vars are not defined. same code is used for both with corona only the php -mysql query changes to get information, but that does not even get called due to the undefined vars in params. the code is like as follow:
local usern = "myName"; local pass = "myPass"; local body = "username="..usern.."&password="..pass; local params = {}; params.body = body; network.request( "http://localhost/myFiles/phpOpenNewUser.php", "POST", networkListener, params );
the php code:
...calling server $nameUser = $\_GET["username"]; $pass = base64\_encode($\_GET["password"]); $sql = "insert into coronatbl2 (username,password,perscode) values ('".$nameUser."','".$pass."','".$myCode."')"; //$sql = "SELECT user\_id FROM coronatbl2 WHERE username='".$nameUser."' and password='".$pass."'"; --commented: replace if \_GET. $result = mysql\_query($sql); mysql\_close($con); echo json\_encode($result);
When I use a query with username and password which I know to exists within the database, with no vars or tables from corona, I still get empty results.
Another thing is that if I use the network request to php with POST I can’t use things like “select * from…” queries, meaning I don’t get any results when asking to get information from the server, and I would like to do both. I get an error with: ‘Notice: mysql_fetch_assoc expected paramater 1 to be resource, got boolean instead’. and i get it each time i try in other ways to get ‘result’ to 'row’s.
Thanks ahead fro reading and if you could help I would appreciate it a lot.