#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0

    Thumbs up SQL Database connecton problem


    Good morning is there anyone that can look at a connection string I am trying to conect to me database with?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,788
    Rep Power
    349
    Originally Posted by McDougall
    Good morning is there anyone that can look at a connection string I am trying to conect to me database with?
    Good evening.
    I'm sorry, I can't see your monitor from over here, so I cannot verify the connection string for you (I can't even tell what kind of technology you are using to do the connection).
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags.
    http://forums.devshed.com/misc.php?do=bbcode#code

    Tips on how to ask better questions:
    http://tkyte.blogspot.de/2005/06/how-to-ask-questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0
    Originally Posted by shammat
    Good evening.
    I'm sorry, I can't see your monitor from over here, so I cannot verify the connection string for you (I can't even tell what kind of technology you are using to do the connection).
    This is the connection string:
    <?php
    $hostname = "localhost:/var/lib/mysql/mysql.sock";
    $username = "root";
    $password = "Mcdougall70";

    //connection to the database
    $dbhandle = mysql_connect($hostname, $username, $password)
    or die(mysql_error());
    echo "Connected to MySQL, Great work<br>";
    ?>

    and this is the Error I get:

    Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/62/11316962/html/securetecaustralia/mysql_connect.php on line 7
    Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)


    Now line 7 is the : $dbhandle = mysql_connect($hostname, $username, $password)

    Sorry for not posting it first however I have post this on a few froums only to find out that its the wrong forums...

    Grant
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,788
    Rep Power
    349
    I have post this on a few froums only to find out that its the wrong forums...
    And... you found another wrong forum.
    Why do you post a MySQL problem in the forum that is titled PostgreSQL?

    (And sorry: I don't do PHP, so I cannot help)
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags.
    http://forums.devshed.com/misc.php?do=bbcode#code

    Tips on how to ask better questions:
    http://tkyte.blogspot.de/2005/06/how-to-ask-questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0
    Originally Posted by shammat
    And... you found another wrong forum.
    Why do you post a MySQL problem in the forum that is titled PostgreSQL?

    (And sorry: I don't do PHP, so I cannot help)
    PostgreSQL thats on this site?
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0

    PHP/Mysql connection Problem


    Is there any one here that can look at my connection to my SQL database string, I will not post it untill I have a reply as I have posted it in a few forums only to be told that the post is in a wrong fourm ...
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0

    SQL Database connecton problem


    Can anyone take a look at my php conection string to connect to my sql database? I will post on reply...
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    158
    Rep Power
    11
    Originally Posted by McDougall
    Good morning is there anyone that can look at a connection string I am trying to conect to me database with?
    Yes, everybody can look at your connect string. :-)

    But perhaps you should anonymize the string (replace the username and password with fake data) and us what errors you are getting, what technology you are using, etc.
  16. #9
  17. Hockey face
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    St. Catharines, Canada
    Posts
    8,147
    Rep Power
    1317
    that is incorrect
    $hostname = "localhost:/var/lib/mysql/mysql.sock";

    use this:
    Code:
    $hostname = "localhost"
  18. #10
  19. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Originally Posted by Guelphdad
    that is incorrect
    No, it's not. This is the syntax for connecting to a specific socket. Read the manual.

    But this whole thread is pointless until we have concrete infos. Does the socket file exist? Does it have the correct rights? etc.

    We still don't have mind-reading skills.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0
    Originally Posted by Jacques1
    No, it's not. This is the syntax for connecting to a specific socket. Read the manual.

    But this whole thread is pointless until we have concrete infos. Does the socket file exist? Does it have the correct rights? etc.

    We still don't have mind-reading skills.
    Yes its does.. what iinfo do you need. I have been chatting to someone else on a site and they have told me to add a line in to the my.cnf file and I have done so this is the line that was added: [client] socket=/var/lib/mysql/mysql.sock

    However I am a windows person I have never worked with LInux, I dont know how to change the read only so I cant save the new line in to the my.cnf file in that folder.

    tell me what information you wiull need and i will pass it on..
  22. #12
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0
    Originally Posted by Vinny42
    Yes, everybody can look at your connect string. :-)

    But perhaps you should anonymize the string (replace the username and password with fake data) and us what errors you are getting, what technology you are using, etc.
    Thanks but at this stage I dont care I just want to get this connection working at I now have to web sites that require database connection and I cant finish them and start to make money, thats the problem I am unemployed and I dont have a money to pay someone to help me here in Australia no one will help you for free, now thats sad but thats the way to world is today...
  24. #13
  25. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0
    Originally Posted by Guelphdad
    that is incorrect



    use this:
    Code:
    $hostname = "localhost"

    This is the error I get no matter what I use: Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/62/11316962/html/securetecaustralia/mysql_connect.php on line 7
    Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
  26. #14
  27. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0
    Originally Posted by Jacques1
    No, it's not. This is the syntax for connecting to a specific socket. Read the manual.

    But this whole thread is pointless until we have concrete infos. Does the socket file exist? Does it have the correct rights? etc.

    We still don't have mind-reading skills.
    In fact the Sock is foind in: /var/run/mysqld/mysqld.sock and not in the loaction shown in the error....


    Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/62/11316962/html/securetecaustralia/mysql_connect.php on line 7
    Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
    Hope that helps
  28. #15
  29. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Originally Posted by McDougall
    In fact the Sock is foind in: /var/run/mysqld/mysqld.sock
    Then you have to write down this exact path in the connection string. You gave PHP the wrong socket path.

    Apart from that, the mysql_* functions you're using are obsolete since almost a decade. They're officially deprecated as of PHP 5.5 (which means every function call will generate a warning), and it's only a matter of time when they'll be kicked out of PHP completely.

    Nowadays, we use the MySQLi extension or PDO:

    How to (properly) access a MySQL database with PHP
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".

IMN logo majestic logo threadwatch logo seochat tools logo