CORONA-PHP-MYSQL: GET does not pass params table. please help

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.

There are several causes of this. If you google “php $_post empty” you will see hundreds of articles on this.  The causes include:

  • not passing the right mime type
  • accessing $HTTP_REFERER instead of $_SERVER[‘HTTP_REFERER’]
  • Accessing a script that goes a 302 redirect (perhaps going from http: to https:) strips post variables
  • making sure PHP has a large enough post_max_size setting in php.ini and make sure it’s set with the right syntax.

and a few others. 

See:

http://geekbrit.tumblr.com/post/1470396976/php-post-array-is-empty

http://stackoverflow.com/questions/1282909/php-post-array-empty-upon-form-submission

Thanks Rob, I am looking into it. most of what is there, does not have anything to do with that, but there might be a problem with how php.ini is configured.

There are several causes of this. If you google “php $_post empty” you will see hundreds of articles on this.  The causes include:

  • not passing the right mime type
  • accessing $HTTP_REFERER instead of $_SERVER[‘HTTP_REFERER’]
  • Accessing a script that goes a 302 redirect (perhaps going from http: to https:) strips post variables
  • making sure PHP has a large enough post_max_size setting in php.ini and make sure it’s set with the right syntax.

and a few others. 

See:

http://geekbrit.tumblr.com/post/1470396976/php-post-array-is-empty

http://stackoverflow.com/questions/1282909/php-post-array-empty-upon-form-submission

Thanks Rob, I am looking into it. most of what is there, does not have anything to do with that, but there might be a problem with how php.ini is configured.