Jump to content

Basic mySQL / PHP Help : Knowing the difference


mydownfall00

Recommended Posts

Hello,

My name is Brian and I am attempting to get setup and connected to mysql database. I am a little ignorant on a few things so try and bare with me.

 

I have just purchased my domain and hosting online. I also have installed mysql server 5.0 . 

 

I am kind of lost between the difference. It's been awhile since I have worked with PHP and I purchased a book from Julie C. Meloni (Sams teach yourself PHP, MySQL and Apache). 

 

I am simply just trying to connect to my database and I cannot connect due to this issue : 

Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2002): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/80/11355280/html/connect.phpon line 10
Connect failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

 

The thing is I am not sure which host to connect to and how I would go about it. On my domains mysql I have a database and table created. I attempt to connect to it with this code : (this is line 10)

 

<?php

$mysqli = mysqli_connect("localhost", "username", "password", "databasename");
 
The username I am using is the username I log in with through a browser. I am not sure if this is correct or if I have to create a user on the database in order to connect.
 
I am also not sure if I would user localhost or my domain url.
 
I created a connect.php file and uploaded it on my server and this is the error it gives me.
 
I use dreamweaver mx for all my hard coding. I am just not really sure on how I get started on all this so I can connect to the database. If anyone could just give me some pointers on what I am doing wrong. I don't mind helping out the person who helps me as well. I know people hate newbie's and I totally sound like a newbie. Im not that bad of a guy and I have a pretty good idea on this im just having issues right now. 
 
This is my fully php code :
 
<?php
$mysqli = mysqli_connect("localhost", "username", "password", "databasename");
 
if (mysqli_connect_errno())  {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}else{
printf("Host information: %s\n", mysqli_get_host_info($mysqli));
}
?>
 
I have attempted to connect to mysql that I installed on my computer and im not able to access that as well. The only thing I attempted to change in the code is localhost to my domain url but that didnt help anything. Just a different error which is :
 
Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2003): Can't connect to MySQL server on 'www.DOMAIN.com' (111) in /home/content/80/11355280/html/connect.php on line 10
Connect failed: Can't connect to MySQL server on 'www.DOMAIN.com' (111)
 
Any help will be much appreciated and I am willing to help someone else anyway I can for there time and effort.
 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.