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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:27:43+00:00 2026-05-24T09:27:43+00:00

I’m having a pretty weird problem with PHP and MySQL. I’m doing the following

  • 0

I’m having a pretty weird problem with PHP and MySQL. I’m doing the following in my PHP script:

$query1 = "SELECT * FROM ".$src;
$ans1 = mysql_query($query1,$vitoquenId);
echo "<p>Query: \"".$query1."\"<br/>Error: \"".mysql_error()."\"<br/>Total rows extracted: ".mysql_num_rows($ans1)."</p>";

When doing this, this is the output:

Query: "SELECT * FROM Almacen"
Error: ""
Total rows extracted: 0

The thing is, I’m not supposed to get 0 rows, and the weird thing is that no error is reported. I granted all the permissions for my user, and even tried connecting to the database as root user, but got the same behavior.

When doing the query directly in the MySQL command line I’m getting the following:

mysql> SELECT * FROM Almacen;
+----+-------------+------------+--------+
| id | nombre      | tipo       | status |
+----+-------------+------------+--------+
|  1 | Tienda      | Principal  | Activo |
|  2 | Dep�sito    | Secundario | Activo |
|  3 | Chaguaramos | Secundario | Activo |
+----+-------------+------------+--------+
3 rows in set (0.00 sec)

I’ve tried using the XAMPP server, and also a configured-by-myself server, and got the same behavior.
I’ve checked every log I’ve thought of, configured MySQL to log every query and nothing abnormal seems to happen.

The MySQL log shows the following:

110802 16:21:49       101 Connect   victor@localhost on 
                      101 Init DB   saw
                      101 Init DB   sawprueba
                      101 Query SELECT * FROM Almacen
                      101 Quit

The Apache log doesn’t show anything, neither the site specific log.

The program I’m writing is a migration tool. It extracts info from one database, processes it, and inserts it into another db. To do so, I need to connect to two databases. I make the connection through two classes using the singleton pattern as suggested in the PHP documentation. You can see the connection file in the github repo.

To make the connection to the db, I call this class like this:

$vitoquen = Vitoquen::singleton();
$newVitoquen = NewVitoquen::singleton();
$vitoquenId = $vitoquen->getId();
$newVitoquenId = $newVitoquen->getId();

What is happening is that for some reason, it does not create two separate connections, but instead create just one connection, and use the second db, the new one, which is empty. I got the clue when I saw the MySQL log:

110802 16:21:49       101 Connect   victor@localhost on 
                      101 Init DB   saw
                      101 Init DB   sawprueba
                      101 Query SELECT * FROM Almacen
                      101 Quit

It shows 101 Init DB twice; one for saw and other for sawprueba. Now I don’t understand why it does not create two separate connections…

  • 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-24T09:27:43+00:00Added an answer on May 24, 2026 at 9:27 am

    Did you select the proper database (also called the scheme) when connecting to your DBMS?

    Example:

    mysql_select_db("mydatabase", $link);
    
    • 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
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am currently running into a problem where an element is coming back from
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I would like to count the length of a string with PHP. The string

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.