Connecting database

Status
Not open for further replies.

zestpanlo92

New Member
Messages
12
Reaction score
0
Points
0
Hi everyone. anyone there can help me? i cant connect my database in x10hosting.com.
pls help me. the error message is "Lost connection to MySQL server at 'reading initial communication packet', system error: 111"
 

MaestroFX1

Community Advocate
Community Support
Messages
1,577
Reaction score
60
Points
0
Could you please post your domain name ?
 

MaestroFX1

Community Advocate
Community Support
Messages
1,577
Reaction score
60
Points
0
What did you use "mysql server name" as ?
It should be localhost.
 

zestpanlo92

New Member
Messages
12
Reaction score
0
Points
0
What did you use "mysql server name" as ?
It should be localhost.

heres my code:

<?php
// Your host, 99% of the time it's localhost.
$db_host = 'localhost';
// Your username for MySQL.
$db_user = 'aianzki_aianzki';
// Your password for MySQL.
$db_pass = 'mypassword';
// And your given name for the database.
$db_name = 'aianzki_greenscarf';

// The database connection.
$con = mysql_connect($db_host, $db_user, $db_pass);
if(!$con) {
die("Cannot connect. " . mysql_error());
}
// The database name selection.
$dbselect = mysql_select_db($db_name);
if(!$dbselect) {
die("Cannot select database " . mysql_error());
}
?>
 

MaestroFX1

Community Advocate
Community Support
Messages
1,577
Reaction score
60
Points
0
Have you granted all the required privileges to the mysql user?
 

zestpanlo92

New Member
Messages
12
Reaction score
0
Points
0
Have you granted all the required privileges to the mysql user?

yes i granted all there permission.. in MySql Database and also to the MySql Database Wizard

---------- Post added at 09:58 AM ---------- Previous post was at 09:52 AM ----------

Have you granted all the required privileges to the mysql user?

Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in /home/aianzki/public_html/connect.php on line 12
Cannot connect. Lost connection to MySQL server at 'reading initial communication packet', system error: 111
 

MaestroFX1

Community Advocate
Community Support
Messages
1,577
Reaction score
60
Points
0
What sort of data are you trying to fetch ?
Is it of type blob? How many tables are there ?
 

MaestroFX1

Community Advocate
Community Support
Messages
1,577
Reaction score
60
Points
0
Just to be safe, I will iterate this:
---------
servername = localhost
username = cpanelusrname_databaseusrname
databasename = cpanelusrname_database
password = password for cpanelusrname_databaseusrname not cpanelusrname

databasename and username should be linked with required privileges set.
---------

Have you tried a standalone php script connecting to your database ?
Like yours aforementioned php script as a standalone .php file!
 

zestpanlo92

New Member
Messages
12
Reaction score
0
Points
0
What sort of data are you trying to fetch ?
Is it of type blob? How many tables are there ?

it has have two tables.. just for a comment and for the data

---------- Post added at 03:22 PM ---------- Previous post was at 10:12 AM ----------

Just to be safe, I will iterate this:
---------
servername = localhost
username = cpanelusrname_databaseusrname
databasename = cpanelusrname_database
password = password for cpanelusrname_databaseusrname not cpanelusrname

databasename and username should be linked with required privileges set.
---------

Have you tried a standalone php script connecting to your database ?
Like yours aforementioned php script as a standalone .php file!

yes.. i tried standalone.. and it connects. but when i import it through online its not working
 

MaestroFX1

Community Advocate
Community Support
Messages
1,577
Reaction score
60
Points
0
but when i import it through online its not working
---------
Import how ? Could please elaborate ?

Is it like

<?php
include ('/blah/somefile.php');
?>

or what ?
 

zestpanlo92

New Member
Messages
12
Reaction score
0
Points
0
i tried it to my xampp the code i use in connecting to database. and it works.. and then.. when i uploaded it to online. the database cant connect no more..

---------- Post added at 03:45 PM ---------- Previous post was at 03:43 PM ----------

but when i import it through online its not working
---------
Import how ? Could please elaborate ?

Is it like

<?php
include ('/blah/somefile.php');
?>

or what ?

in short the website that i create is working on LAN BASED using my XAMPP..
 

MaestroFX1

Community Advocate
Community Support
Messages
1,577
Reaction score
60
Points
0
<?php
mysql_connect("localhost", "cpanelusrname_databaseusername", "databaseusername_password") or die(mysql_error());
echo "Auth Pass<br />";
mysql_select_db("cpanelusrname_databasename") or die(mysql_error());
echo "DB Con Pass";
?>

Save it - example.php

Try this here on x10.
Post your results back.
 

zestpanlo92

New Member
Messages
12
Reaction score
0
Points
0
here's the result:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'aianzki_aian'@'web3.vital.x10hosting.com' (using password: YES) in /home/aianzki/public_html/connect.php on line 2
Access denied for user 'aianzki_aian'@'web3.vital.x10hosting.com' (using password: YES)
 

MaestroFX1

Community Advocate
Community Support
Messages
1,577
Reaction score
60
Points
0
here's the result:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'aianzki_aian'@'web3.vital.x10hosting.com' (using password: YES) in /home/aianzki/public_html/connect.php on line 2
Access denied for user 'aianzki_aian'@'web3.vital.x10hosting.com' (using password: YES)

Check your database user password (not cpanel user password).

Grant cpanelusrname_databaseusername all the reuired privileges to the cpanelusrname_databasename.

Use :
cPanel >>MySQL Databases >> Current Databases
Click the cpanelusrname_databaseusername to open
MySQL Account Maintenance

Manage User Privileges

User: cpanelusrname_databaseusername
Database: cpanelusrname_databasename

Set the required PRIVILEGES (Just grant all PRIVILEGES)

---
Also, if the cpanelusrname_databaseusername alongside cpanelusrname_databasename doesn't show upin the above table ; use "Add User To Database" and click add.
 

zestpanlo92

New Member
Messages
12
Reaction score
0
Points
0
yes i tried that many times.. but it does not work. i check all the PRIVILEGES also in the mySQL database wizard..
hiazt... tommorow is my deadline... :(
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
cPanel --> Remote MySQL

Please post the IP's listed
 
Status
Not open for further replies.
Top