1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

N00b Question: Super Simple MYSQL Question (Please HELP!)

Discussion in 'Plesk for Linux - 8.x and Older' started by TylorFamous, Jun 17, 2008.

  1. TylorFamous

    TylorFamous Guest

    0
     
    (thanks for reading this!)

    Ok, I have only done some really simple MYSQL stuff with php. I was using a mysql db that came with a domain name I got through godaddy and just some simple PHP. And to connect to my database I would need a user name, password, host and database name.

    Now my question where do i find the host name with the MYSQL db's that I make in PLESK? Is it my ipaddress? Because in the past the host name was something like 123.343.45.34.securerver.net or something like that.

    Please give me any info. That would be awesome! Thanks :)
     
  2. wsani

    wsani Silver Pleskian

    28
    40%
    Joined:
    Mar 4, 2005
    Messages:
    509
    Likes Received:
    0
    Try localhost for the hostname.
     
  3. TylorFamous

    TylorFamous Guest

    0
     
    Nope that didn't work :(

    Error:

    Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'DOMAINNAME'@'SERVERNAME.prod.phx3.secureserver.net' (using password: YES) in C:\Inetpub\vhosts\DOMAINNAME.com\httpdocs\test\dbtest.php on line 6
    Error connecting to mysql
     
  4. wsani

    wsani Silver Pleskian

    28
    40%
    Joined:
    Mar 4, 2005
    Messages:
    509
    Likes Received:
    0
    oh, hmm okay. I guess the MySQL server is remote? Is it on the same box or a different machine? Is SERVERNAME.prod.phx3.secureserver.net your Plesk server?
     
  5. TylorFamous

    TylorFamous Guest

    0
     
    Like I said I am kind of new so I don't know what you mean by remote...? I made the server by going to:

    Domains > www.DOMAINNAME.com > Databases > Add New Database > (and then i enter the info)

    Here is the php code I am using, if that helps:
    <?php
    $dbhost = 'localhost';
    $dbuser = 'USERNAME';
    $dbpass = 'PASSWORD';
    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
    $dbname = 'TABLENAME';
    mysql_select_db($dbname);
    ?>

    And here is the Error I get with that code:
    Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'domainname'@'localhost' (using password: YES) in C:\Inetpub\vhosts\domainname\httpdocs\test\dbtest.php on line 6
    Error connecting to mysql

    (The error I posted before was what I got when I used my server's IPAddress, sorry about that)
     
  6. wsani

    wsani Silver Pleskian

    28
    40%
    Joined:
    Mar 4, 2005
    Messages:
    509
    Likes Received:
    0
    Let's take a few steps back. Did you setup a user on your database after you created the database?
     
  7. TylorFamous

    TylorFamous Guest

    0
     
    Yes I did create a user. And I didn't even think about using those logins. Is this the login name/password I should use?

    Well I tried it and I no longer get any MYSQL errors (which i think is a good thing!) but I also don't get any information when I try to get it. I do though, get a error that I think is just from my PHP code.

    Error: No database selected with query SELECT * FROM `shows` WHERE `showid` =1

    Here is my PHP Code.
    <?php
    $dbhost = 'localhost';
    $dbuser = 'USERLogin';
    $dbpass = 'USERPASS';

    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

    $dbname = 'shows';
    mysql_select_db($dbname);

    $query = "SELECT * FROM `shows` WHERE `showid` =1";
    $result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query);
    $row = mysql_fetch_array($result);
    extract($row);

    echo "This show is:";
    echo $showname;
    ?>

    Thank you for all your help though!
     
  8. TylorFamous

    TylorFamous Guest

    0
     
    Ok, my last problem was because I didn't have a database name in my code. But I am so happy to say that everything is working PERFECTLY and I can't thank you enough! You truly have saved more pulled out hair than you can possibly imagine!!!

    Thanks!
     
Loading...