PDA

View Full Version : panel.byethost.com mysql question



chopficaro
01-04-2010, 07:02 AM
Ive been trying to learn php, and Ive just gotten to the chapter about mysql and im trying to test it on my web site, which uses http://panel.byethost.com/
http://panel.byethost.com/ provides some mysql control, but i don't want to use it, i want to send every command through php, because im trying to learn php. so i grabbed some code from w3schools.com and inserted my username, password and mysql host name into it. i uploaded the code onto the server, ran it and got this error:

Could not connect: Access denied for user 'space_4826174'@'192.168.0.110' (using password: YES)

heres my code, or rather, the code from w3schools.com:




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-…
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>mysql test</title>
</head>
<body>
<?php
$con = mysql_connect("sql307.000space.com","spa…
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

if (mysql_query("CREATE DATABASE my_db",$con))
{
echo "Database created";
}
else
{
echo "Error creating database: " . mysql_error();
}
mysql_close($con);
?>
</body>
</html>



im absolutely sure that i have the correct username, password and host. anyone who uses http://panel.byethost.com/ knows that the mysql username and password are the same ones u use to log into cpanel or access via ftp. and once u log into http://panel.byethost.com/, it tells u right away what the mysql host is, here ill copy and paste it:
MySQL hostname: sql307.000space.com

so why did i get this error?

Nile
01-04-2010, 06:30 PM
You got this error because your password, user, or host was wrong. I know your absolutely sure, but check one last time. Also, not many people code MySQL like above, but they code similar. Try:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-…
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>mysql test</title>
</head>
<body>
<?php
mysql_connect("sql307.000space.com","spa…", "") or die("Could not connect: ".mysql_error());
mysql_query("CREATE DATABASE my_db") or die("Error creating database: ".mysql_error());

?>
</body>
</html>


Also, you should make sure you put an "@" sign in front of your mysql functions if you decide to code like that. The "@" symbol suppresses any errors or warnings.

chopficaro
01-05-2010, 03:50 PM
turns out that if your host uses panel.byethost.com, you cant create databases via php u have to do it in the panel, i just hope they dont waste any more of my time on things like this