#Connect MySQL from Unity

1 messages · Page 1 of 1 (latest)

stark sage
#

I know

#

So you have ID/PW then what is your concern?

#

Of course you’d need read only access ID for client
Or create web server

hollow sundial
#

my concern is I have no experience with PHP or MySQL and I've looked through a bunch of tutorials and cant figure this out

stark sage
#

Ah then why not use something easier

#

I think Firebase Database can do something like that

hollow sundial
#

i've already set up the MySQL databse. I can figure this out. The issue is just I've seen and tried so many tutorials and I don't know best practice

#

I don't wanna build a whole user/pw high score board like all these tutorials

stark sage
#

You could use single hardcoded ID/PW with read permission for all client if that is the case

hollow sundial
#

i'm most looking for the optimal tutorial to walk me through the process right now.

stark sage
#

I don’t know your environment
You want to create PHP web server connecto to MySQL and retrieve the value that I understand?

hollow sundial
#

yep

stark sage
#

Well let’s see I think you need to reference ‘display.php’ part and customize query

#

You don’t need to add score or anything

hollow sundial
#

yeah I can change all the top stuff fine. the try catch is the connecting part.

I dont get whats happening starting with $sth and below. is that part pulling the top 5 scores so i just cut all of it

stark sage
#

Yeah you can just limit 1 if you want one result associated with request value

hollow sundial
#

one row but ~20 fields from the row

stark sage
#

And you can make it to json with json_encode and echo to return?

#

So it would be single page and request body with value from client

#

Returns json object of your row

#

That’s pretty much it I think

hollow sundial
#

i'm trying to look up these things your saying

idk this is what my data looks like. probably?

#

yes I think json_encode will do what I need if it can find the right row

stark sage
#

So select with limit 1 then echo the json encoded row and exit

#

And others are up to client

hollow sundial
#

from square one: you think I shoudl write a PHP file, put it on my website. The top area with user and host stuff explains user and pw to the MySQL database. That one file is all I need and I need to edit that file you shared above to now just have that json_encode statement?

stark sage
#

Yes that is what I think. If your server set up correctly to process php

hollow sundial
#

ok thanks. wish me luck!

stark sage
#

I wish you a good luck
It won’t be so hard to test since it’s readonly and all

hollow sundial
#

thanks. it's 3am here i'm going to bed and trying again tomorrow morning.

#

i'll get it though 🙂

stark sage
#

You will! Have a good rest