I have created this drag and drop application using Actionscript, and would like to send variables from here to a MySQL database. But before that, I intend to store the variables as session variables.
I'm not really sure on how to go about doing this and I haven't found anything much online that is relevant. Could someone show me how the PHP and Actionscript side code looks like?
Thank you very much in advance!
No-one here is going to write all that code for you.
The simple stages would be like this;
Have a PHP file for each service (maybe called "writeVariable" and another called "readVariable"). Decide on some way to pass information to and from them - maybe using JSON or XML, or just plaintext. The services would then write and read the data from the database as needed.
Then access those pages from flash through URLLoader and the protocol you set up.
Related
Is it possible to enter HTML form data into a database with SQL without using a PHP script?
It is possible to do it without using a PHP script, but not without using some kind of server-sided script. if your database is stored on a server. It doesn't have to be PHP, it just needs to be something that can take your form data and pass it to the database. Or if your database is stored on your client PC, you could do it there I guess.
No you can't (so far my knowledge goes, i never heard of it anyway) plus you might get into big security problems as you have no control of injection attaks. Always use a server language of any kind (php, asp, python, java or similar) and validate all data before it gets pushed to the database. anyway you can pull data directly with html/xml (old fashined way) but still i think of leaks! my advice to begin with would be a framework what does the job for you in a secure/ save way like laravel, symfony, yii2 or doctrine. there is very much example code and your learning curve for php might be easier thank plain php.
here's the link to the old fashion way of getting data without php but not sending it to the db directly:
https://smallbusiness.chron.com/insert-form-mysql-51070.html
Sorry if this is formatted incorrectly, this is my first time posting here.
So I'm trying to have this database of items be able to be checked out and returned from a web browser.
I've written up a web page in html that would work, if not for me having no idea how to have user input save serverside.
Plus I have no idea where to host this. I'm kind of in over my head here, any tips on where to start?
If you want to do it all yourself, I'd check out some shared hosting services that offer a database + php.
Html itself can't interact with the server / store data like that. That's where PHP would come in to play, and then either MySQL/Postgres/etc would store the data.
You should have a read up on some basic PHP and learn how it interacts with databases, then you can have a form submit and store the data, then render it on another page.
I have researched APIs and I generally understand how they work and how to use them (HTTP request to API, get data and parse it, etc.), however, for my project I need to use data that I collected myself so I can't just use another database for example. I'm quite new to this so I don't understand a few things. I'll try to explain my plan as clearly as possible. Please let me know if any additional explanation is required.
I have an HTML form which can be filled out and saved. This form is not supposed to be local, but rather on a server
I read a lot about XML-files and API's and I also saw many similar questions on here but I'm not sure what applies to my instance.
I wanted to store the information from the form in an XML-file. Some people said, that this could be done with JavaScript, some people said this would require some server-side script. What applies in this case? I would guess that I need a server-side script but as I said, I'm kinda at loss here.
I thought I could simply use JavaScript to store whatever is entered into the form and use python or php to create an XML-file in which I store this information. This XML-file would then be used by the API. This is were I have trouble understanding.
The edited form is supposed to be saved (on the server I guess, so several people can access it), so you can go back to it later and edit it again. How exactly would I implement an API here? Can I just "make" my own XML-file, which the API uses as database? Is there any better way to do this?
I know this probably seems like a stupid question but I really want to understand this so bear with me. I'm very much overwhelmed by this task so I appreciate any help.
Ok I found a few questions on how to get data from a MYSql database into an iOS app, but I am just asking a few best practices here. I know these can all be separate questions, but I am hoping that they can be answered in a way that they relate to each other.
Am I correct to understand that to be able to get data into an iOS app - I need to first generate a JSON file, have that stored on a server and than have the app download this file??
If the previous answer is NO then does that mean, I can pull in data on the fly?
Lastly I have seen PHP examples to create JSON files, but iOS is in Objective-c. Does this mean I need to load a UIWebView to be able to load the PHP page that generates the file?
What I have:
I have a MYSql database - it is set up through PHPMyAdmin, so I am not familiar enough with the creation process of the database yet. I will look into that.
I can also export the JSON file from PHPMyAdmin, but that is no good to me in a iOS app.
I also have the parsing from a JSON file into an iOS app sorted, but I want to be able to do this on the fly instead of creating potentially hunderds of files.
I hope someone can help me here:-)
I am not necessarily asking for code, but would be mad to ignore it:-)
The problem is that there are not any iOS libraries for directly connecting to a MySQL server; and you really wouldn't want to do that, anyway. So, you need an intermediary server capable of sending data in a format your iOS application can understand. Note, this does not mean the data has to be JSON formatted. But it is very easy to use JSON as the format for your data. Most languages have native support for generating JSON from its native object format(s).
Once you have a server capable of sending data in your preferred format, you need to write some way for your iOS application to retrieve it. You do not have to use a UIWebView for this. As mentioned, the NSURLConnection framework is very easy to use to make such a request. However, there are a lot of other factors to consider when making network requests and others have already done most of the work for you. I like using the AFNetworking framework in conjunction with JSONKit. AFNetworking makes asynchronous calls to remote web services very easy, and JSONKit is nicer than NSJSONSerialization in my opinion.
What I do to retrieve data from MySQL to my iOS app is:
Create a PHP file on your server and prepare it for GET methods (you're going to send data from the iOS app)
Send a request from your iOS app to your php file, like: "www.yourdomain.com/data.php?name=..."
Process the information on your php file and echo the json output.
When connectionDidFinishLoading: convert the NSData to an Array using NSJSONSerialization.
Do whatever you like with the output information
That's just do way I do. I'm not familiar with other approaches.
PHP (and any other server side language) can take the data from the MySQL database and output it to any client as JSON, on the fly. No need to save the JSON to disk beforehand. Of course, from the client's point of view, there really is no fundamental difference (except the data will always be the latest representation of what's in the database).
You also don't have to use a UIWebView. There's a number of ways to make an HTTP request using Objective-C, but you'll likely want to look at something along the lines of NSURLConnection's sendSynchronousRequest:returningResponse:error: method (I prefer using synch methods inside an async block, but that's not the only way). You can find many tutorials on how to do similar things, as well as higher level libraries to simplify the process.
I need to generate HTML snippets using jQuery. The creation of those snippets depends on some data. The data is stored server-side, in session (where PHP is used).
At the moment I achieved this
- retrieving the data from the server via AJAX in form of JSON
- and building the snippets via specific javascript functions that read those data
The problem is that the complexity of the data is getting bigger and hence the serialization into JSON is getting even more difficult since I can't do it automatically.
I can't do it automatically because some information are sensible so I generate a "stripped" version to send to the client.
I know it is difficult to understand without any code to read, but I am hoping this is a common scenario and would be glad for any tip, suggestion or even design-pattern you can give me.
Should I store both a complete and a stripped data on the server and then use some library to automatically generate the JSON from the stripped data? But this also means I have to get the two data synchronized.
Or maybe I could move the logic server-side, this way avoiding sending the data. But this means sending javascript code (since I rely on jQuery). Maybe not a good idea.
Feel free to ask me more details if this is not clear.
Thank you for any help
There are several Javascript/jQuery templating solutions available. John Resig is working on one that's likely to become a popular jQuery add-on, if not part of the core distribution. Kyle Simpson is also doing one.
I googled for a reference to it, but really I'd suggest doing your own searching because there's lots of good information out there.
edit well here's a pretty good link: http://www.west-wind.com/Weblog/posts/509108.aspx
You can use PHP's json_encode and json_decode methods to convert native PHP objects into JSON data representation.