I am trying to develop an android application. In the application the user can search some data from the database that is on the server side. For that, I use a php script that is on the server side along with mysql database. I give it a call from the android app and the php code connects with the database and returns a json result which I decode and use it as I want.
My question is this. Can this support multiple users at the same time? For example 2 different users use at the same time the search function for retrieving data from the database. I know that the database itself can handle this kind of requests, but what about the php service?
Here is an example of the php code:
<?php
mysql_connect("host","username","password");
mysql_select_db("Deal");
$sql=mysql_query("select * from CITY where CITY_NAME like 'A%'");
while($row=mysql_fetch_assoc($sql))
$output[]=$row;
print(json_encode($output));
mysql_close();
?>
PHP script is being launched by web-server environment. It's hard to imagine there exists web-server that doesn't support multi-threading at present. So, don't worry. The answer is positive.
Related
I have a simple question about the database structure and connection to my iOS App.
Is there any solution to get datas from my databse using Swift without PHP output? I want a PHP script which connects to the database and echo the result. The app should load the datas directly from the database like PHP (mysqli).
It is really important for me to protect the datas in the database! Nobody should see the datas when he opens a URL in the browser of my server.
I would like to create a website that shows analysis of my Odb database. Therefore I need to extract data from orientdb, in a "live way" i.e connect and open the database via php, query my database and stock into variables the results. I found one API written in php that is supposed to stream data from Odb but it's not working.
Do you know if there is any way to do like the php command mysqli (that connect to mysql and allows you to query the database) but with orientDb ??
Thank you
I hope will be of help, to these two links:
OrientDB-PHP
Graph-in-php-through-OrientDB
the guides are shown to connect to OrientDB via php.
I would like your help on these. Does anyone know how to get data from arduino to a database? Specifically mysql or any other database that we can use.
You need a backend on your server. The Arduino calls a php script with POST or GET Parameters and the php script writes the content to your database.
Add some HTTP Basic Auth and the job is done,
A while back I wrote a rather long javascript procedure for organizing data we receive at work. The user simply paste in the mess we get and script throws out all the worthless info and generates a nice cleaned up data table.
I would like to add the ability to then transfer the processed information to the mySQL database. I'm growing a bit more comfortable using javascript, but I don't have close to the time or know-how to recreate the long processing procedure in PHP. How should I prep the data in javascript to most efficiently hand off the data to the server and have PHP insert it into mySQL tables?
The less PHP server side the better, although I doubt it would be safe to have a PHP page that blindly followed any instructions a referring page might send it.
At this point the data my script presents in the browser looks a lot like mySQL records already.
ex.
(Wilson, Paul, 1000400, A399)
(Smalls, Kalah, 4993944, B11)
(Chase, Danny, 244422, B133)
(Larson, Jay, 3948489, J39)
...
Thanks!
If you could have the data in a JSON array.
Then on the php side use json_decode to pull the data in as an array loop through it and do your updates and inserts for your data in MySQL.
http://php.net/manual/en/book.json.php
I would like to clear my doubts in hooking up of MySQL database with XCode.
My application would need to retrieve data from MySQL as there would be a login screen.
As such, in order for me to retrieve data from my database, there is a need for me to create a database using MySQL and connect it using PHP and then connect PHP to XCode?
I am a greenhorn in application developing but I am tasked to do it for my school.
I would need great help in creating a PHP in connecting MySQL(it would be good if its steps-by-steps guide). I would really truly appreciate your kind generous reply.
Thank you in advance!
It is very simple to connect to a MySQL database with PHP. There are a couple of APIs for this, mysql and mysqli. Mysqli is probably the better one to use, but mildly denser. The Mysql one works like this:
$db = mysql_connect("host:port", "username", "paswword");
mysql_select_db("my_db", $db);
# say we want to select everything from the table Persons
$result = mysql_query("SELECT * FROM Persons");
while ($row = mysql_fetch_array($result))
{
# do your magic
# columns are accessed in a zero based array
# such as $row[0], $row[1], etc.
# look at mysql_fetch_assoc to see how to access
# using the column names
}
mysql_close($db);
There's what looks like an older but still valid W3c tutorial here and the MySQL PHP API reference there. To learn about the API differences read the Overview of the MySQL PHP drivers.
As the other answers have stated you'll want the PHP to output something like JSON or XML to communicate with your app and the XCode.
This tutorial follows the whole process through step by step from creating a web service to implementing the web service in your app. I found it super easy to follow.
Part 1:
http://www.raywenderlich.com/2941/how-to-write-a-simple-phpmysql-web-service-for-an-ios-app
Part 2:
http://www.raywenderlich.com/2965/how-to-write-an-ios-app-that-uses-a-web-service
It sounds like you need some sort of WebService. What you can do is just create your PHP pages and let them output a set format (say JSON or XML). Then in your Obj-C application just do the webrequests and parse the results.
There might be some existing solutions which you can use, Webservice is the keyword here.
Here what sounds better to connect to a mysql database, your best bet is to use JSON/SOAP/XML/PHP websevices to talk between your database and your app..
The reason database connection directly from the device is a bad idea, is that you have to enable global external access to it for it to work. You can keep your data safer by having scripts on your server do the communication to the database.
One example of how to do this is create PHP pages that export XML data as your mysql data export , and use GET POST methods to post data to PHP pages to write to your database..