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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:40:00+00:00 2026-05-26T22:40:00+00:00

I’m opening up a project from last year and figured I’d try MAMP on

  • 0

I’m opening up a project from last year and figured I’d try MAMP on the new computer, seemed kinda cool.

Looks like it’s all running, PHP works, and I rebuilt the database in phpMyAdmin.

After adding some test data to the tables, I made a simple test (see files below), but I couldn’t retrieve anything from the database.

When I load test-basic.php it says “Connected to db. Selected database. Found Nothing =(“

But I tested the string in phpMyAdmin (for the ‘likeiwassaying’ database) and it returned the results

I feel sooooo close (and have been banging my head on this for hours). Am I missing something right under my nose?

Any troubleshooting suggestions appreciated,

Justin

config.php

<?php
    $dbhost = 'localhost';
    $dbuser = 'root';
    $dbpassword = 'testpassword';
    $dbdatabase = 'likeiwassaying';
    $config_sitename = 'Cully Mail';    
    $config_author = 'jk';
    $config_basedir = 'http://localhost:8888/cullymail/';

    $db = mysql_connect($dbhost, $dbuser, $dbpassword);
    if (!$db) {
        die('Could not connect: ' . mysql_error());
    } else {
        echo 'Connected to db. ';
    }

    $db_selected = mysql_select_db($dbdatabase, $db);
    if (!$db_selected) {
        die ('Can\'t use: ' . mysql_error());
    } else {
        echo 'Selected database. ';
    }

    mysql_close($db);       

?>

test-basic.php

    require("config.php");

    function test() {
        $q = 'SELECT * FROM contacts;';

        $result = mysql_query($q);
        $numrows = mysql_num_rows($result);


        //If it is found (if any row comes back)...
        if($numrows == 0) {
            echo "Found nothing =(";
        } else {
            echo "found something";
        }

    }

    test();

?>
  • 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-05-26T22:40:01+00:00Added an answer on May 26, 2026 at 10:40 pm

    You’re closing your database connection before executing your function test(). You close the connection at the end of config.php, meaning that by the time the function is defined in test-basic.php the db connection already no longer exists and further queries will fail.

    You don’t usually need to call mysql_close() explicitly, unless you have a need to regain memory resources early. PHP will close down the connection when the script completes.

    $db_selected = mysql_select_db($dbdatabase, $db);
    if (!$db_selected) {
        die ('Can\'t use: ' . mysql_error());
    } else {
        echo 'Selected database. ';
    }
    
    // Everything is good so far. you're ready to execute queries, but...
    
    // Don't do this!!!
    mysql_close($db);  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.