How do i connect my .php to phpmyadim? - php

I need help on creating a basic log-in page and registration page. I only know the basic stuff on php. And my boss told me to use the database he created online (phpmyadmin). So how do I connect the .php file I created to the online database? I have experienced connecting it to a database. But not the one that's online. Any help please? Thank you!

Firstly, PhpMyAdmin is not a database. It is a PHP based database admin tool to ease the management of databases so that you don't need to do the "boring" commandline interface stuff.
Assuming that it's actually just a MySQL database, then you can connect it using mysql_connect().

if you know how to connect it to the local database, it's always the same: you need a server address (localhost, IP or domain), database name, username and password.
read more here:
http://php.net/mysqli
http://php.net/mysql

Related

PHP use symlink to connect on right database

I have multiple databases (with same schema) used by multiple users. Each user has his own database. Some data of these databases need to be accessible by the public.
First I thought my structure like that: To access the database of user2, I connect to http://user2.mysite.com/public. If I want to see datas of user8, I connect to http://user8.mysite.com/public. It works great, but if I want a SSL I need a wildcard certificate, cheaper than a standard certificate.
Someone told me symbolic link can help me.
So I created another domain name and I would like that when someone connect on mysite.com/user1 he can see database of user1, if I go on mysite.com/user9 I connect to database of user9 to see public datas.
Someone told me I can create a symbolic link (mysite.com/user1) and in it I can put a config file with parameters to connect to the database of user1. I look for this but I can't find anything in docs.
Do you have any idea? Thanks a lot.

External MySQL Database for a Website

Is it possible to create and use a MySQL database outside of my website host and link it to my website.
For example, using freehostia.com, my website is being hosted with one MySQL database to handle the WordPress Application installed. I want another database to use for SourceBans, and have it accessed at MyWebsiteName.com/bans, but freehostia.com only allows free users to have one database.
Is it possible to create another database somewhere else and use it on my website?
Yes, You can.
You can separate out your application server and the database server. But there are configurations that need to be done in order for such architecture to work. This is mostly done due to security and scalability.
Please kindly elaborate your requirement so that I can help you.
Other users already that yes you can, I want to show a simple approach on you gonna do it.
Simple when you are connecting to an external Database , you can use the mysql's server IP as your host when trying to connect using PHP.
For example in PHP:
$host = "192.182.0.124";
$use = "username"
$pass = "pass";
$db = "your db name"
$conn = new mysql ($host,$user,$pass,$db);
If your dababase is in the same server as your application, use localhost in $host or use the IP or host name of the database server if the server is external.
most PHP applications has a config file. database connection is mostly in the config file, for example, wp-config.php is the file WordPress use to store the database connection. Find out which file your php application is using to connect to database and change the database host to the IP of the external server.
Yes, it is pretty much possible and doable.

Connecting to an oracle database using web service

I have an android application that should connect to a database to retrieve some data to be shown on the screen.
The only method I know is to connect to mySQL using local host.
But how to connect to a real oracle database using the web service which is written in PHP.
Please help me since I didn't find any related information like this.
This is works for me in past, I hope its works for you too.
http://www.codeproject.com/Articles/112381/Step-by-Step-Method-to-Access-Webservice-from-Andr
http://www.c-sharpcorner.com/uploadfile/88b6e5/how-to-call-web-service-in-android-using-soap/

How to connect a sqlite database in remote host

i have been in a problem to connect to a sqlite database in remote host. I have already gone through alot of research on this, it seems not possible, but using rest api (building web services) can solve this problem. I can't use web services to interact with DB for my application.
Additional details,
is it possible to use path as http://192.168.0.6/computer_a/computer_a.sqlite ?? I have tried this but not working
my code
$db = new SQLite3($comAdb) or die('Unable to open database');
$comAdb -> http://192.168.0.6/computer_a/computer_a.sqlite
Please help
Thanks
No. You have to give a path on a file system.
You could use cURL to download the database, save it locally and then access it.
Can you create a file system mapping to the remote directory, where the second database resides?
Then you can just use ATTACH

Problems connecting to a remote server and performing a simple db query

I have set up a website with basic HTML/CSS files and would like to take that one step further and implement a database with some PHP to perform simple queries and whatnot.
My problem arose when I noticed while setting up the database and creating the PHP files that connect to the database (on my local machine), I used 'localhost' as an argument for mysql_connect. When I then went to drag and drop my newly created HTML/PHP files along with my database into FileZilla to upload the pages onto my remote server, there was a problem connecting to the database. I have a feeling that it is unhappy with the whole 'localhost' notion - yet I don't know what to change it to.
Currently, I am using this line of PHP code to connect to my remote database (which is all located in FileZilla-land).
$link = mysql_connect('localhost','Tommy','pass')
Also, as another quick question: does my remote server have its own phpMyAdmin page? And if so... how would one go about finding it? =D
I appreciate anyone who is able to assist me in my endeavors.
Thank you!!
Log on to your database server, check the details and obtain the correct server information such as server, username and password.
Once you change the server details you shoudl be ready to rock n roll. Edit post with the host name/server name and we may be able to find it for you.
You'll have a phpMyAdmin page where you're hosting the site. Check the membership area or cPanel.
You are right in that 'localhost' in mysql_connect needs to be different. 'localhost' is a textual representation of a loopback address AFAIK - it connects to the computer it is hosted on. As you have uploaded it to your server (a different computer) it is now trying to connect to a mysql server on the server host, instead of your home computer (which holds all the data).
To make this work you'd need to get your database onto the server you are now working from, OR depending on your home setup, point it to your local database.
Whether your host has MySQL/PHPMyAdmin available to you is another matter altogether. If they have MySQL it is probable but not definite that they have a phpmyadmin interface.
Contacting the server host will yield more information. If they have MySQL, it is probably as simple as getting the required details from them, and 'backing up' your SQL on your local server and uploading it to the new server (easily done with PHPMyAdmin)
TL;DR: The database you are trying to connect to doesn't exist on the server you're connecting from.

Categories