Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php "connections" mysql database problem

    Hello folks..my first post here and im in a bit of a quandry with php and connecting to mysql.. heres the basis of the problem.. My host wont let me access MySQL directly from dreamweaver so i have MySQL set up on localhost with phpmyadmin to connect...
    heres my problem my site is in php as some of it is dynamic and i need to collect registratio info for a members database, when i've built the necessary pages and database on localhost he thing runs as good as i want it to with no problems, registration is not a problem, information of the registrant is collected and left in the relevant table in MySQL (on localhost of course)
    now heres where it all goes wrong..i upload everything to my hosts server. same database details are held on that MySQL server,yet it always fails at this point

    Warning: mysql_pconnect() [function.mysql-pconnect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /websites/LinuxPackage02/uk/_k/is/uk-kiss.com/public_html/Connections/ukkiss.php on line 9

    Fatal error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /websites/LinuxPackage02/uk/_k/is/uk-kiss.com/public_html/Connections/ukkiss.php on line 9
    would i be right in saying that my localhost must have the same username/password etc as my hosted MySQL so that my connections folder (well the file thats in there) can connect to my hosted Mysql database or could i just edit the file in connections folder?..or as i fear is there lots more to this..thanks for your time..

  • #2
    New Coder
    Join Date
    Dec 2006
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can you post your connection line so we can see it?

    I know some places have both MySQL4 and MySQL5. In order to connect to MySQL5 you have to do something like:
    PHP Code:
    /* Connecting, selecting database */
        
    $link mysql_connect("localhost:/tmp/mysql5.sock""user""pass"
    Notice the part after localhost? Check with your host provider to see how they want you to connect to the database.

  • #3
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    @ crimsonjade thanks for the quick reply, Im a total newbie at this so im kinda wondering what you mean by conections string, how would i get to find that out?

  • #4
    New Coder
    Join Date
    Dec 2006
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    By "connection line" I meant the line of code that shows us how you are connecting to your MySQL database from within your script.

    For example:
    PHP Code:
    $link mysql_connect('localhost''mysql_user''mysql_password');
    if (!
    $link) {
       die(
    'Could not connect: ' mysql_error());
    }
    $result mysql_query('SELECT name FROM work.employee');
    if (!
    $result) {
       die(
    'Could not query:' mysql_error());
    }

    mysql_close($link); 
    Before I submit a query, I need to specify which database I am connecting to. If you do not have a line with the mysql_connect() function in it, you are probably not connecting to the database.

    If you do not know where to add the mysql_connect() line, post your script here so we can see it and help you out. If you do post your script, make sure to hide any sensitive information (e.g. the username/password to your database).

  • #5
    New Coder
    Join Date
    Dec 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I may be missing the point here and if so please forgive me. I use a config.php file for the sql connection strings. I two have a localhost and a hosted mysql and web server. I make the scripts on my localhost and then upload them to the server. Instead of putting the username and password and host in the file itself I just use something like this. All the mysql connection and database selection strings are kept in the config.php file.

    Code:
    include 'config.php';
    $result = mysql_query('SELECT name FROM work.employee');
    if (!$result) {
       die('Could not query:' . mysql_error());
    }
    
    mysql_close($link);
    This way, when I upload the file the mysql info changes without me doing any of the editing.

    Also, can you connect at all? Because most hosted mysql database will (even though you register with say scriptin as the mysql username your username will actually be scriptinghelp_scriptin and if you create the hosted database as employee the database conection will have to actually be scriptinghelp_employee.)

    Who is hosting your Mysql Database. That will also help us out.
    Last edited by SELF_TAUGHT; 12-25-2006 at 05:00 AM. Reason: Left something out....sorry.

  • #6
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sorry for the delay in replying,xmas festivities etc!..

    Well herein lies a problem with config.php i cant seem to find one the only config. files that i have are config.inc and config.default...
    the site im building contains just 3 pages index.php,register.php (this is the page im having problems with) and a thankyou.php which the user returns to after entering there details on the register page,, the error im getting is

    Warning: mysql_pconnect() [function.mysql-pconnect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /websites/LinuxPackage02/uk/_k/is/uk-kiss.com/public_html/Connections/ukkiss.php on line 9

    Fatal error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /websites/LinuxPackage02/uk/_k/is/uk-kiss.com/public_html/Connections/ukkiss.php on line 9
    and here is the first line of code on "register.php" page

    <?php require_once('Connections/ukkiss.php'); ?>
    <?php
    below is the file it points too with the error on line 9

    <?php
    # FileName="Connection_php_mysql.htm"
    # Type="MYSQL"
    # HTTP="true"
    $hostname_ukkiss = "localhost";
    $database_ukkiss = "********";
    $username_ukkiss = "********";
    $password_ukkiss = "********";
    $ukkiss = mysql_pconnect($hostname_ukkiss, $username_ukkiss, $password_ukkiss) or trigger_error(mysql_error(),E_USER_ERROR);
    ?>
    below is a reply from my host "pipex" which to a newbie like me doesnt exactly clear things up
    The file at...

    /websites/LinuxPackage02/uk/_k/is/uk-kiss.com/public_html/registration.php

    ..is referencing a file:

    ./Connections/ukkiss.php

    ..which the server looks for at:

    /websites/LinuxPackage02/uk/_k/is/uk-kiss.com/Connections/ukkiss.php

    ..and, because this doesn't exist, it throws an error.

    You need to review your code, or find out how to set /websites/LinuxPackage02/uk/_k/is/uk-kiss.com/public_html/ as the document root on the remote server in your publishing software. This should be able to work with just public_html , as that is the web root in relation to your FTP home.
    any ideas?..thanks
    Last edited by Martinj; 12-26-2006 at 02:57 PM.


  •  

    Posting Permissions

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