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

  • Home
  • SEARCH
  • 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 8005279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:11:05+00:00 2026-06-04T17:11:05+00:00

I am scratching my empty head with this issue: When I have my logging

  • 0

I am scratching my empty head with this issue:

When I have my logging data as procedural, everything works fine. I require the file once and can proceed with my select queries. If the connection to the DB file is however written as OOP. I get the error that No database selected

====

<?php

        // SETTING VALUES AS CONSTANTS

        DEFINE('DB_USER', 'root');
        DEFINE('DB_PASSWORD', '');
        DEFINE('DB_HOST', 'localhost');
        DEFINE('DB_NAME', 'tra');

        // CONNECTING JUST TO THE SERVER
        $dbc = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);

        if (!$dbc)  // IF IT CAN'T CONNECT, ISSUE A MESSAGE
             {
                die('Could not connect: ' . mysql_error());
        }

        // CONNECTING NOW TO THE DB
        mysql_select_db("tra", $dbc);

    ?>

So that up there works fine. I have got that in a separate file, (out of the root path)

But if I try to do it OOP, then, the rest of the queries that are to work once I have the access to the DB won’t work. I sometimes get the query written as output, I mean as if not executing, just the plain text:

   $mysqli = new mysqli("localhost", "root", "");
            $mysqli->select_db("tra");

I have tried tons of varieties with the OOP version, first instantiating separately such as

$mysqli = new mysli();
$mysqli->connect("127.0.0.1", "root", "", "tra");

or also

$mysqli = new mysqli("localhost", "root", "");
$mysqli-> select_db("tra");

but none of the tries with OOP will work. I mean, I have the book on my lap, so I am writing it ad litteram. The issue must be elsewhere.

The PHP version is 5.3.8 about the latest one.

The sql query that follows after the connection and selection of the DB (which works if the connection file is procedural, as I say) is:

$sql ="SELECT FName
                              FROM work_assignment, developer
                              WHERE developer.country = '".$country."'
                              AND work_assignment.from_language = '".$from."'
                              AND work_assignment.into_language = '".$into."'
                              AND work_assignment.developer_id = developer.developer_id

                              ";

Any ideas as to why?

Thanks a lot

  • 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-04T17:11:07+00:00Added an answer on June 4, 2026 at 5:11 pm

    From your comment I surmise you’re mixing the mysql and mysqli extensions. They are two separate extensions with nothing in common, except that they both connect to MySQL. If you’re connecting to the database using a mysqli object, use that object to run your queries. mysql_query will have no active connection, because you did not establish one using a mysql function.

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

Sidebar

Related Questions

Scratching my head here: I have an application which works fine in Debug+Release if
I've been scratching my head over this for an hour... I have a list
I have been scratching my head for a while on this one. I dont
I have been scratching my head for hours trying to figure out why this
I am scratching my head over this, but have no idea what the problem
I have been scratching my head over this for days and I still cannot
This has me scratching my head. I have a view controller that implements UIPopoverControllerDelegate
I've been scratching my head for quite some time now, this code worked fine
I have been scratching my head on this for a while now but still
I have been scratching my head on this one for a while, so I

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.