Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8856983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:29:02+00:00 2026-06-14T14:29:02+00:00

I recently learned about PDO so I changed my php files to fit the

  • 0

I recently learned about PDO so I changed my php files to fit the format and now I am getting back this response:

ERROR: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

I did not change the connection variables just the format to fit PDO. I am running a Bitnami Lampstack (5.3.16-0) and did what the documentation said as far as uncommenting the line for PDO with mysql in the php.ini file. I am wondering if it has to do with my mysql.sock file which has a size of 0.

My PDO connection looks like this (I added the unix_socket and port pieces because they were mentioned in another question relating to this error but they didn’t seem to help):

$dbConnection = new PDO('mysql:unix_socket=/opt/lampstack-5.3.16-0/mysql/tmp/mysql.sock;host=$dbhost;port=3306;dbname=$dbname;', $user, $pass);

apache, mysql, httpd, ect are all running fine on my server and this only came up after enabling PDO.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:29:03+00:00Added an answer on June 14, 2026 at 2:29 pm

    First, your connection string in your example is single quoted, so variable substituion won’t work. Use double quotes if you are intending to use the contents of the variables $dbhost.

    Second, you should not specify both a local socket and a host/port. Pick one or the other. I am guessing from your post the socket wasn’t the original intention.

    Try this:

     $dbConnection = new PDO("mysql:host=$dbhost;port=3306;dbname=$dbhost", $user, $pass);
    

    Also, your example points the dbname to the $dbhost variable. Is this a typo?

    Sockets are all 0 bytes. They are just named pipes that can be read and wrote to, but they themselves have no contents. Just verify the socket exists if you want to use it.

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently asked about functional programs having no side effects, and learned what this
I recently learned about sockets in Java and sending information back and forth from
I recently learned about strides in the answer to this post , and was
I recently learned about ActivePython as a convenient way of quickly getting Python up
I have recently learned about PDO and and Doctrine 2.2.2 to build an application.
I recently learned about IKVM.net which is a Java for Mono (.NET). So I
I've just recently learned about friend class concept in C++ (I've googled around for
Recently I learned about Werkzeug's interactive debugger in combination of django_extensions to debug Django
I learned HTML and CSS about 8 months ago, and recently, about 2 months
I have recently learned to create dynamic links via php, but my problem today

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.