Php MySQL noob

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Kyle12345
Posts: 4
Joined: Sat Mar 02, 2013 6:35 pm

Php MySQL noob

Post by Kyle12345 » Sat Mar 02, 2013 6:43 pm

Ok, so I'm new to livecode and php. So far I have been able to create a simple php script on my host server to query a MySQL database.

What I'm trying to figure out is how I pull those results into livecode. I understand how I can call the URL for the php script, but I'm not sure how I would take query results from the php script and put them into variables in my livecode application.

Essentially what I'm trying to do is pull results from the database and create a clickable list, that would let the user drill down into that result with the rest of the info from that row.

I hope that makes sense, any help would be appreciated.

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: Php MySQL noob

Post by bangkok » Sat Mar 02, 2013 7:26 pm

Yes, it makes sense. :) And it's very simple.

-create a very simple php script that will display the result of query. nothing more.

like "SELECT * FROM MY TABLE"

After in livecode do something like :

Code: Select all

put URL "http://www.mysite.com/myscript.php" into myResults
answer myResults
Now, more complicated : you want to pass a parameter to your php script (a string that your php script will use to query the database)...

Code: Select all

put "HELLO" into myParameter
put "myparameter="&urlencode(myParameter) into leMessage
post leMessage to url "http://www.mysite.com/myscript.php"
put it into myResults
answer myResults
Of course, in your PHP script you have to handle the POST.

To go further :
-you will have to take care of security
-by using encryption
-by doing a "sterilization" of the parameters you send to the PHP script (to avoid "injection attacks")
-you'll find on this forum some discussions about it

Last possibility : doing the same with... LiveCode Server :D Soon opensource !

Kyle12345
Posts: 4
Joined: Sat Mar 02, 2013 6:35 pm

Re: Php MySQL noob

Post by Kyle12345 » Sat Mar 02, 2013 8:39 pm

Great! I've got everything almost working as needed...minus the security side. (I'll need to spend more time researching that).

One further question that may be less obvious to answer. When I test my code in live code itself it work perfectly fine and populates the list. When I test it with iOS simulator it does not populate the list. Any thoughts on that?

Thanks for the help!

Post Reply