views:

53

answers:

3

Hi everyone,

I am developing Smoking counter and I need to send all the smoking record (about the time user smoking) to database on the server. The server database is MySQL database. I knew that I must have send data to PHP page/script, and this page/script will run on the data to insert record to database.

I would like to know: is there another way to update database, because I don't have knowledge about PHP. I used to work on java and c/c++/objective-c. If you know another way to do this task, please let me know.

Any help would be appreciated.

+1  A: 

You may use any server side solution you like which has a MySQL interaction class library, e.g. Java servlet or C/C++ CGI application. You will also need a web server (e.g. Apache or Apache Tomcat) which will take care of HTTP requests.

PHP is not the only way to write programs which use MySQL.

vadimbelyaev
Thank you for your reply
haisergeant
+2  A: 

If you already know Java, C and C++, then you should be able to learn how to write your php script really quickly, just google a tutorial.

While could run a Java server using a servlet to insert the data, PHP is far easier to deploy, and you should only need to write a few lines of code.

I you do use PHP though one thing to remember when inserting to your database is to run all your parameters to add through mysql_real_escape_string

Edit: To give an example, this script when configured would insert a name and location to a database:

<?php
$link = mysql_connect("hostname", "username", "password");
mysql_select_db("databasename");
$location = mysql_real_escape_string($_POST['location']);
$person = mysql_real_escape_string($_POST['person']);
mysql_query("INSERT INTO mytable(location, person) VALUES('{$location}', '{$person}')");
mysql_close($link);
?>
DrDipshit
Yes, I can learn PHP to write some script. But I would like to ask, after I write the PHP page/script, where can I upload that page because the database is on server. Do I need to upload that page on the same server?Sorry because this is maybe a stupid question.
haisergeant
Your PHP script would need to run on a server running PHP. If the DB is on a remote server then the DB server would need to allow remote connections, which is generally not a good idea unless you know what you're doing due to mysql injection attacks.
DrDipshit
Ok, I understand. Thank you very much.
haisergeant
Your php has to be on a webserver that supports php. Your database can be in a different server(doesn't have to be on the same server that php is in). You just have to set up the php mysql_connect so that it points to the database server.Web servers that support php - LAMP(Linux), WAMP(Windows)
Mowgli
A: 

http://ODBCrouter.com/ipad (new) has XCode client-side ODBC (Open Database Connectivity) libraries, header files and multi-threaded Objective C objects that would let you access MySQL through the official MySQL ODBC driver installed along side of an ODBC Router (there are screen shots of this at that link). The XCode-side is free, the ODBC Router costs about the same as a TV set (ie, less than developing and separately maintaining a SOAP/REST server).

AugSoft Tom