I am new to PHP and mysql and i am trying to make API’s for my iphone app.
So far i have been able to connect and retrive data from my sql database now m trying to make entries to it using API’s and parameters.
Can anyone help me out here please.
Thanks alot!!
If by
to make entriesyou mean adding data to the database.You do this in the same way that you
selectdata.Instead of issuing a
selectstatement like:You do:
Or:
How you pass parameters depends on the API you use.
It is best (safest) to use PDO to pass parameters.
How to get parameters out of a url
In order to get the parameters out of the url (e.g.: example.com/test.php?username=xyz&password=!@#$%) do:
Note that it’s vital to put single quotes around the injected variable names when using
mysql_real_escape_string()or the escaping will be useless. Used like this the code is 100% secure from SQL-injection.If you’re using PDO, you can drop the
mysql_real_escape_string()if not you need it to prevent SQL-injection.Links
http://dev.mysql.com/doc/refman/5.5/en/update.html
http://dev.mysql.com/doc/refman/5.5/en/insert.html
http://php.net/manual/en/ref.pdo-mysql.php
https://stackoverflow.com/search?q=%5Bphp%5D+%5Bmysql%5D+pdo
http://php.net/manual/en/reserved.variables.get.php
http://php.net/manual/en/function.mysql-real-escape-string.php