I'm creating a php page (on a godaddy server) which needs to connect to a mysql server and retrieve data from a database. When i run the page i got an error message stating that.
Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on **
It says that the error is on the below line,
$conn=mysql_connect($dbhost,$username,$password);
My doubt is,
What needs to be given in place of username and password? Right now i've given the username and password used while creating a new database inside mysql. What am i doing wrong?
Thanks in advance...
Do not use "localhost" as the hostname for your database-driven websites. Once you have successfully created a database, your host name displays on the Database Information page of your hosting Control Panel.
To Find the Host Name for Your Database
Log in to your Account Manager.
Click Web Hosting.
Next to the hosting account you want to use, click Launch.
In the Databases section of the hosting Control Panel, click MySQL or MSSQL depending on the database type for which you want the host name.
From your list of databases, click Actions next to the database you want to use, and then click Details.
Your database host name displays in the Hostname field.
On shared go daddy DB's you can't use localhost for the $dbhost
you will need to use the location specified in your godaddy mysql cp
Related
I have developed POS using the laravel framework. I want to connect my hosted account MySQL database local running laravel application. please help me to way to save data in cpanel MySQL server.
You need to enable mysql remote access in your cpanel.
Log into cPanel. Click the Remote MySQL button in the Databases
section. Enter the remote IP address in the Add Access Host section.
Click the Add Host button. You will then see a message stating the
host IP address was added to the access list.
For more with images i have found https://www.inmotionhosting.com/support/website/databases/setting-up-a-remote-mysql-connection-in-cpanel
Sorry i cant write as comment because of rep.
Im realy new into this php and android online database thing,So I really ask to somebody to fix my problem.
Im using mysqli_connection and I need my host name for this query ;
$con = mysqli_connect($host,$user,$password,$db);
But the problem is I dont know what is my host my phpMyAdmin site look like this
https://hike.veridyen.com:2083/
and I'm entering my site from this url;
http://dobo.us/atakan/
so what is my host name please ?
If you are using a shared hosting it should be located as follow:
After creating your database, you can find its details, including its
hostname, in your control panel.
Log in to your GoDaddy account.
Click Web Hosting.
Next to the hosting account you want to use, click Manage.
In the Databases area, click MySQL or MSSQL depending on the database type for which you want the host name.
From your list of databases, click Actions next to the database you want to use, and then click Details.
Your database's details displays including its username, host name,
and a link to reset its password.
Instructions above are for GoDaddy, but should give you a general sense of direction.
For SiteGround, use 'localhost'
I'm trying to hook up my website to my MySQL database on my new webhost, and I'm running into a few issues I can't resolve.
If I navigate to mywebsite.com/phpmyadmin/, I'm presented with an HTTP authorization, and upon successful entry of that, my PHPMyAdmin login page, where I can log-in as my user and see my databases. Yet, if I try to connect via PHP through my website, I receive the error:
SQLSTATE[HY000] [2005] Unknown MySQL server host 'mywebsite.com/phpmyadmin' (11)
My connection info is:
$this->dbh = new PDO('mysql:host=mywebsite.com/phpmyadmin;dbname=mydb;charset=utf8','me','myPassword');
I'm running LAMP on Ubuntu 14. Is there any particular reason this is failing?
PHPMyAdmin is a database client application, not a database server.
You need to provide connection information to your database server (which will probably be localhost)
You need to connect to the mysql server rather than the phpMyAdmin interface (won't work).
In this case it's you will use localhost (Really). Why? because localhost just points to the server's local IP. You can also point it to any hostname which points to the server's IP so it knows which server to connect to! :)
I've created an ODBC connection to my MySQL cPanel. I've made the settings in System DSN and when I press TEST Connection the message that returns is succesful. I've added the IP as a wildcard. Then I'm going in the SQL Server Management Studio to create the linked server. I fill up with the dates, I choose "Microsoft OLE DB Provider for ODBC drivers", but when I press OK the following error is showing up:
The linked server has been created but failed a connection test. Do
you want to keep the linked server?
Cannot initialize the data source object of OLE DB provider "MSDASQL"
for linked server "GRUPSAPTE". OLE DB provider "MSDASQL" for linked
server "XXXXXXX" returned message "[MySQL][ODBC 5.1 Driver]Access
denied for user 'gsapte'#'XXXXXXXXXX' (using password: NO)".
(Microsoft SQL Server, Error: 7303)
I've created many linked servers for localhost but when I'm trying to create for my webserver it shows the error above. Do I have to make some changes to the webserver or some access things?
Any advise will be much appreciated.
have you checked that the IP address you are coming from is allowed for the login? When I have used MySQL in a hosted environment, the mysql server checks if the user who is requesting access is coming from a known\permitted IP address. Don't know if this is the problem, just one similar to what you are asking.
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.