I was just wondering if there was an easy way that anybody has figured out, to send MySQL queries through Computercraft. Would it work to just send the query through an HTTP request? How would I format everything in Computercraft, and then unformat it in PHP to send the request? Also, how would I receive info back from the MySQL server? Has anybody made an API for something like this?
MySQL in Computercraft
Started by elfin8er, Jan 14 2014 02:42 AM
3 replies to this topic
#1
Posted 14 January 2014 - 02:42 AM
#2
Posted 14 January 2014 - 03:16 AM
it is not a good idea for security purposes to allow requests that supply the SQL query. You're best to request a particular url with specific details, for example usernames and such. Then the PHP code would go ahead and use those details and insert them into an SQL Prepared Statement (take note of terminology, its another security tip) and perform the request on the database, returning the information to the webpage for your ComputerCraft script to pick up.
Giving code is something we generally do not do here in Ask a Pro, we give pointers and tips in order to help you find your solution; as such here are some resources for you to achieve the task you wish to perform
- php get
- php post
- mysql php
- mysql php prepared statements
- http api
Note: if you are not familiar with PHP, MySQL, or security with either, please do not attempt what you're trying to do, I've given you only the first steps towards security, not the total solution. There have been too many failed attempts that've lead to security problems on the forums, we don't need more.
Giving code is something we generally do not do here in Ask a Pro, we give pointers and tips in order to help you find your solution; as such here are some resources for you to achieve the task you wish to perform
- php get
- php post
- mysql php
- mysql php prepared statements
- http api
Note: if you are not familiar with PHP, MySQL, or security with either, please do not attempt what you're trying to do, I've given you only the first steps towards security, not the total solution. There have been too many failed attempts that've lead to security problems on the forums, we don't need more.
#3
Posted 14 January 2014 - 03:23 AM
theoriginalbit, on 14 January 2014 - 03:16 AM, said:
it is not a good idea for security purposes to allow requests that supply the SQL query. You're best to request a particular url with specific details, for example usernames and such. Then the PHP code would go ahead and use those details and insert them into an SQL Prepared Statement (take note of terminology, its another security tip) and perform the request on the database, returning the information to the webpage for your ComputerCraft script to pick up.
Giving code is something we generally do not do here in Ask a Pro, we give pointers and tips in order to help you find your solution; as such here are some resources for you to achieve the task you wish to perform
- php get
- php post
- mysql php
- mysql php prepared statements
- http api
Note: if you are not familiar with PHP, MySQL, or security with either, please do not attempt what you're trying to do, I've given you only the first steps towards security, not the total solution. There have been too many failed attempts that've lead to security problems on the forums, we don't need more.
Giving code is something we generally do not do here in Ask a Pro, we give pointers and tips in order to help you find your solution; as such here are some resources for you to achieve the task you wish to perform
- php get
- php post
- mysql php
- mysql php prepared statements
- http api
Note: if you are not familiar with PHP, MySQL, or security with either, please do not attempt what you're trying to do, I've given you only the first steps towards security, not the total solution. There have been too many failed attempts that've lead to security problems on the forums, we don't need more.
#4
Posted 14 January 2014 - 04:26 AM
elfin8er, on 14 January 2014 - 03:23 AM, said:
So because of that, would it work to send the query directly to PHP via an HTTP request?
Edited by theoriginalbit, 14 January 2014 - 04:28 AM.
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











