I built a stock manager on VB.NET, it uses a MS Access Database. I also built a website, and on this website I want to relularly upload the updated MS Access database file onto the website and insert it into the mySql Database. Now my problem is I dont know how to access the MS Access file using php, im sure theres a way without buying those softwares, but i cant find it. Now I not bound to this scenario, if someone has better ideas i would appreciate it, most importantly I want the stock management to be offline, and at the end of the day, i want it uploaded to the site.
Thanks alot
I have done that in the past using ADODB and JET:
// connect
$conn = new COM('ADODB.Connection');
$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={$database};Mode=ReadWrite;");
//query
$results = $conn->Execute($sql);
// retrieve
$results->Fields[$field]->Value;
// navigation
$results->MoveNext();
$results->Move($count);
$results->EOF();
// Close (don't forget)
$conn->Close();
This is just a small sample. More Help
Look into php_odbc which has the ability to communicate with MS Access if you have correctly configured an ODBC data source on the PHP server. php_odbc documentation here.
// From the `odbc_connect()` documentation:
// Microsoft Access
$connection = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=$mdbFilename", $user, $password);
Related
I have been developing a plugin for Wordpress and I am stuck at point where I have to connect my plugin to a database remotely.
I know the procedural way of estabilishing the connection to a database which looks something like this $link = mysqli_connect("hostname", "username", "password", "database");
The $link variable will either return true or false depending on connection status, in my case the plugin is not allowed to connect to my MySQL server due to Administrator restrictions.
I have few questions regarding this.
What do you do in cases like these? If one enables the access via MySQL dashboard on a single database to make the connection, would that make a database vulnerable to injections or less protected?
If the previous is the right way, how do you pass the parameters properly to a function without revealing the plain credentials?
Is there any other way to implement this logic to get the needed data that plugin requires?
P.S. I have already tried looking up here for an answer without luck, the PHP documentation also did not help.
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.
So I'm brand spanking new to mysql and php.
I'm set up with Mysql workbench and I'm practicing building a site using Notepad++ and just run it through Chrome. All I want to do is create a sign up page, which I'm assuming I use a .php page on the site, where it would be a username and password. That's it. I can't seem to find any tutorials on how to connect mysql to the .php page, or how to create a sign in page. Any help would be appreciated!
Welcome to PHP!
Typically a connection is established on a PHP page with something along the lines of this:
$conn = mysqli_connect("localhost","[username]","[password]","[databasename]") or die("Error " . mysqli_error($conn));
The "or die" will produce an error if there's a problem establishing a connection. Also, this uses the newer "mysqli_" method for connection; make sure when you call this connection in future that you use mysqli_ methods (there are still traditional "mysql_" methods available, but are depreciated).
Hope this helps!
M
here you go you, here you can find a way to properly connect to the database as well as all the data you need to get set up with your signup form
http://mrbool.com/how-to-create-a-sign-up-form-registration-with-php-and-mysql/28675
I am developing a simple app with mysql database with one table. I update local database daily. But every week I want to update it to remote mysql database by clicking a button. I know about the synchronization and replication in PHPMyAdmin. But I don't want to use it.
I successfully checked the remote and local database connection from a file.But unable to get solution of synchronizing.
Is there any method to do synchronization in PHP?
There are many articles I have read but all articles are giving methods using replication and synchronization. As I have to deliver this app to a client. I want to give him the simplest solution.
*I have cPanel,PHPMyAdmin access to remote database.
Thanks in advance.
check this http://www.heidisql.com/ using this software if you update in your local system it will automatically update in your remote server.
If you're going to update a remote database I would do it in real-time rather than just once a week. It gives you a real-time, offsite backup and it's also easier for you to code.
In PHPMyAdmin you can create a new MySQL user who has rights to your remote database. It's better to create a user account that has ONLY the privileges required to update your remote database rather than using the "root" MySQL user which has all privileges.
Then you just modify your existing PHP files and everywhere you execute SQL against the local database you add a command to execute the same SQL against the remote database. For example:
(this code is untested, may contain syntax/logic errors)
<?php
$local_dsn = 'mysql:host=localhost;dbname=my_database';
$local_username = 'my_local_username';
$local_password = 'my_local_password';
$remote_dsn = 'mysql:host=remote_ip_address;dbname=my_database';
$remote_username = 'my_remote_username';
$remote_password = 'my_remote_password';
$local = new PDO($local_dsn, $local_username, $local_password);
$remote = new PDO($remote_dsn, $remote_username, $remote_password);
$sql = 'UPDATE my_table SET column1 = ? WHERE id = ?';
try{
$local_stmt = $local->prepare($sql);
$local_stmt->bindValue(1, $column1);
$local_stmt->bindValue(2, $id);
if ($local_stmt->execute() && 0 < $local_stmt->rowCount()){
$remote_stmt = $remote->prepare($sql);
$remote_stmt->bindValue(1, $column1);
$remote_stmt->bindValue(2, $id);
$remote_stmt->execute();
}
}catch(PDOException $e){
echo "An error occurred processing sql statement ($sql):" . $e->getMessage();
exit;
}
?>
It's difficult to tell if you are able to access your remote database from your local Windows machine or not. You say "I successfully checked the remote and local database connection from a file." which to me implies that you CAN access the remote database from your local machine but then you say "I have cPanel, PHPMyAdmin access to remote database" which implies you do not have access to the remote database from your local machine...
If for some reason you cannot access your remote database from your local machine you'll need to create at least one PHP page on the remote server that can execute the same SQL queries that you're executing locally. You'll want to use a secure connection (HTTPS) and pass some kind of authentication credentials (at the very least some kind of hash or encrypted key) along with the SQL to be executed.
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..