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 8360117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:21:49+00:00 2026-06-09T11:21:49+00:00

I have a test db on godaddy, I have had a similar issue before

  • 0

I have a test db on godaddy, I have had a similar issue before but with the help of stackoverflow it was solved.. So I have actually used the same solution however now I am having a host of errors when I try to load my php file from the browser.

Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/97/8603797/html/countryQuery.php on line 14

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/content/97/8603797/html/countryQuery.php on line 14

Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/content/97/8603797/html/countryQuery.php on line 16

Warning: mysql_close(): no MySQL-Link resource supplied in /home/content/97/8603797/html/countryQuery.php on line 18
Database Output

I have read what the problem is and some of the things I have read suggest I am not connecting to the DB correctly.. but I am only doing what I have read/been told and dont really know what else I can do to solve the issue I am having…

this is my php code, if anyone has and suggestions or solutions I would greatly appreciate hearing from you.

<?

 $hostname = 'mydatabasename.db.6666666.hostedresource.com';
  $database = 'mydatabasename';
  $username = 'myusername';
  $password = 'secretsecret';

  // establish a connection
  $db = new PDO("mysql:host=$hostname;dbname=$database",$username,$password);


$query="SELECT * FROM `Countries`";

$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

echo "<b><center>Database Output</center></b><br><br>";

$i=0;
while ($i < $num) {

$country=mysql_result($result);

echo "<b>$country<br>";

$i++;
}

?>

the out put should just be a list of the country names I have in the countrys table of my database.. which has values in it.

  • 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-09T11:21:50+00:00Added an answer on June 9, 2026 at 11:21 am

    You are mixing PDO and mysql_* functions.

    Try something like this:

    $db = new PDO("mysql:host=$hostname;dbname=$database",$username,$password);
    $db->setAttribute(PDO::ATTR_AUTOCOMMIT, true);
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    
    $sql="SELECT * FROM `Countries`";
    
    $numRows=$dbh->exec($sql);
    echo "There were $numRows selected with:<b> $sql </b><br><br>";
    $db=null;
    unset($db);
    

    When it comes to getting data from the PDO connection, I normally do something like this using the FETCH_INTO option:

    $stmt = $db->query($sql);
    $obj = $stmt->setFetchMode(PDO::FETCH_INTO, new userStructure);
    // I do normally have a class matching the row I wan:
    
    foreach($stmt as $userStructure)
    {
        $someObject->year=$userStructure->year;
        $someObject->month=$userStructure->month;
        unset($stmt);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this test slider http://jsfiddle.net/dUyLY/2/ In Chrome it works nice, but in firefox
I have test code as below. test1 passes the test but test2 failed when
Trying to get www.example.com/test.php?archives=testing to www.example.com/archives/testing According to godaddy they have mod_rewrite enabled by
I've tryed mylyn but i cant find that feature, if anyone have test mantis
Actually I had a single domain (example.com) which is hosted in godaddy hosting account,
I have Test controller and Test agent installed on a virtual machine VM1. Test
I am creating a traceability matrix for PRD. I have test case _id which
I have a Test Class, that test the access of all page with different
I have a test sample about coherence lock-unlock mechanism like this: public class Test
I have this test [Test] public void SaveInventoryItemLoad_Will_Call_WCF_Service_SaveInventoryItemLoad() { adapter.SaveInventoryItemLoad(new List<InventoryItemLoadProxy>()); itemMasterBusinessClientMock.Verify(x => x.SaveInventoryItemLoad(It.IsAny<List<InventoryItemLoadProxy>>()),

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.