Results 1 to 3 of 3

Thread: panel.byethost.com mysql question

  1. #1
    Join Date
    Dec 2009
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default panel.byethost.com mysql question

    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:

    Code:
    <!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?

  2. #2
    Join Date
    Jan 2008
    Posts
    4,167
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    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:
    PHP Code:
    <!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.
    Jeremy | jfein.net

  3. #3
    Join Date
    Dec 2009
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •