Database Error

heshma.patel41

New Member
Messages
1
Reaction score
0
Points
0
Hi I have uploaded my website on my account with X10hosting.com but my site is not hosted properly i m getting error:Database Error: Unable to connect to the database:Could not connect to MySQL plz help me on this how to resolve this error... I really appreciate for u'r support
Thanks
 

aaron.is.me45

New Member
Messages
10
Reaction score
0
Points
0
:Database Error: Unable to connect to the database:Could not connect to MySQL
Things to check would be
you have the correct password, the correct address of your mysql server, and that the user is actually connected to that database (if your using your main account name you shouldnt have that problem) and that your using your userid_databasename
 
Last edited:

chance.brown65

New Member
Messages
9
Reaction score
0
Points
0
I am seeming to have the same issue, I am also new

trying to use PHP to connect to the MySQL database on x10hosting.com,

not to sure if I got the server address correct, but that would be on myPHPadmin page on the right panel correct ? (IE: 10.33.249.7)



Here is my PHO code, for obvious reasons I have substituted the password


Code:
<?php
$con = mysql_connect("10.33.249.7","back2fro_username","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

 print "CONNECTED";

  

mysql_close($con);
?>




any help in getting connected would be perfect, the error I am getting is this, I do know my username and password are 100 correct, i reset them numerous times and created multiple users just as a test


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

Anna

I am just me
Staff member
Messages
11,739
Reaction score
579
Points
113
you should ALWAY have host as "localhost" on our servers, anything else will fail.
 
Last edited:

chance.brown65

New Member
Messages
9
Reaction score
0
Points
0
Ok, so I changed my 2nd line of PHP code to show 'localhosr' and also tried 'localhost' as a test and came up with 2 errors

localhosr - code error
Code:
Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'localhosr' (1) in /home/back2fro/public_html/OHL/asc1.php on line 2
Could not connect: Unknown MySQL server host 'localhosr' (1)

**Assumption: this hostname is incorrect, as then I tried localhost...

localhost - code error

Code:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'back2fro_users'@'10.33.248.79' (using password: YES) in /home/back2fro/public_html/OHL/asc1.php on line 2
Could not connect: Access denied for user 'back2fro_users'@'10.33.248.79' (using password: YES)




** here is the full PHP code again..

I do understand my Username for x10hosting, which is 'back2fro' needs to be displayed at the beginning of my user who logins to sql so I created a user named "users". so i Put back2fro_users, and the password corresponding to that SQL user
Code:
<?php
$con = mysql_connect("localhost","back2fro_users","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

 print "CONNECTED";

  

mysql_close($con);
?>
 
Last edited:

Anna

I am just me
Staff member
Messages
11,739
Reaction score
579
Points
113
If that would be what's located in your test.php, it seem to work fine now?

And yes, sorry for the confusing typo I made.
 

chance.brown65

New Member
Messages
9
Reaction score
0
Points
0
Yep, that is exactly it in my test.php

I guess I must of had a space somewhere, my code works fine now after retyping it all out completely from scratch.


thank you for the localhost info, was useful as well, previously I was using freehostingcloud and they have really slow servers, and after finding x10, I am interested in becoming a full member just because of the speeds!! but I shall wait till I finish past the first book of learning SQL/PHP for my iPhone apps.



I hope I can provide some insight in the future on this forum regarding iPhone connection to PHP/MySQL databases on X10
 

Anna

I am just me
Staff member
Messages
11,739
Reaction score
579
Points
113
quick note on that part, free hosting does not allow connection to the database from an outside source. In other words a webpage located in your account can connect fine, but connecting directly to the database from say your home computer will not work, which means that if the iPhone is to connect to the database directly it will fail in free hosting.
 

chance.brown65

New Member
Messages
9
Reaction score
0
Points
0
Thank you for that information ANNA, right now I am currently using a simple PHP script to Print a section of my SQL, multiple PHP files, for testing purposes, and now have it working perfectly, however before I goto Distribution of my app, I will be sure to get a premium account to have such feature to connect remotely. So I can have my php files housed in my iPhone app, similar to as what i did with (MAMP)

**as you can see I am working on a sport app**

IPhone code:
Code:
NSURL *awayshotfinalurl = [NSURL URLWithString:@"http://back2front.x10.mx/phpcontentgoeshere.php"];
	NSString *awayshotfinalstring = [NSString stringWithContentsOfURL:awayshotfinalurl encoding:NSASCIIStringEncoding error:nil];
	ashFINAL.text = awayshotfinalstring;






I have also created a JSON script and used the JSON Touch De Serializer scripts to decode my JSON code, which connects to my database, this outputs the information is a really nice friendly TableView Controller. I will post that code later in another topic



all in all, signed up to this site last night, got stuck, now I solved my #1 issue, and everything seems promising, give me another week or two, and I should be ready to start deploying out some applications i have been working on these past few months, finally!!
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Just a heads-up: the old mysql driver is quite outdated and has been supplanted twice over. Especially if you're creating a new site, switch to the newer PDO driver. Among it's advantages are support for prepared statements, which do away with most SQL injection vulnerabilities. If you want a PDO tutorial, try "Writing MySQL Scripts with PHP and PDO".
 
Top