Challenges with integrating Wampserver PHP 5.3.1 and Pear:DB

After successfully installing PHP5.3.1 on top of 5.3.0 on my Windows 7 Pro laptop, along with Smarty, Pear and relevant Pear packages, I have encountered a strange issue. I have separate development and production sites set up using a config.php file - the former on Win and the latter on Linux. A thorough check of phpinfo confirms that everything is properly configured.

However, when attempting to access my home page (the login page) on version 5.3.1, it hangs for about a minute before displaying a blank screen without any error messages. After some troubleshooting by hiding parts of the config file, it seems like the code snippet below may be the culprit:

require_once "DB.php";
$db = DB::connect("mysql://root:$dbpass@$dbhost/$dbname") or die("unable to connect to $dbhost");
$db_hw = DB::connect( "mysql://root:$dbpass@$dbhosthw/egret" ) or die("unable to connect to $dbhost_hw");

I specifically have two different database servers in use for my service. Strangely, even the die("") statements are not showing up.

If anyone has any insights or suggestions on what could be causing this issue, please feel free to share your thoughts!

Sincerely, George

Answer №1

This is a common issue experienced by many developers. When using mysql_connect or mysqli_connect, you receive a resource back that allows you to manage your queries effectively:

How can I connect to multiple MySQL databases on a single webpage?

However, when utilizing PEAR and accessing the same class DB::connect, it results in overwriting the database resource and connection.

To address this problem, simply invoke the disconnect() function before establishing a new connection:

require_once "DB.php";
$db = DB::connect("mysql://root:$dbpass@$dbhost/$dbname") or die("Unable to connect to $dbhost");
$db->disconnect();

$db = DB::connect( "mysql://root:$dbpass@$dbhosthw/egret" ) or die("Unable to connect to $dbhost_hw");

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

I must adjust the size of images based on the size of the viewer's screen

Hello everyone, I could really use some assistance as I am not an expert programmer but just a site admin. My issue is this: I have a website running on PHP and I want to display images to my members while keeping them within specific size limits so they ...

Ordering MYSQL Results Based on the Count of Rows in a Different Table

I have 2 Tables: 1 - dog Breed|category 2 - teams Id|teamname|category I am looking to organize the data from the dog table based on the number of entries in the category (team) table. For instance, in the teams table, the category column contains: ...

"Optimizing website performance with Ajax and securing data with

As I work on developing an Ajax chat application, I have found the need to periodically call a PHP script that checks for new messages in the database. I recently learned about PDO prepared statements and thought they could be useful since only one variab ...

"Upon parsing the JSON data, the decoder yielded a null

This question has been asked many times before, but I am still struggling to get it working. I have a JSON and when I dump the $TenentsAccessible output, it looks like this: string(71) "[{`TenantID`:`test.com`,`Name`:`12thdoor`}]" I need to extract the ...

How to implement AJAX to call a servlet from a PHP page

I'm currently attempting to receive a response from a servlet page and display an alert on success. However, I keep encountering errors every time. I can't seem to pinpoint the issue. Here's my AJAX code: $(document).ready(function() { $ ...

Running an rsync shell command through a PHP script in a web browser

At first, our objective is to transfer modifications from one system to another using a shell script named synchfolders.sh. The content of the file is as follows: rsync -av --delete -e 'sshpass -p Wordpress@123 ssh -p 22' <a href="/cdn-cgi/l/ ...

File appears to be empty after passing through ajax request

I have encountered an issue with my ajax submit function. When I submit the function, worklogdetailsidschedule and shift_schedule are successfully inserted into the database. However, the filename_schedule, which is a file, appears empty in the database. ...

When the button is clicked, initiate the download of a file and include a parameter containing the desired value to be

If there is a change in the table on the index page triggered by a specific event, another file called excel.php can be used to generate an Excel sheet. To run the excel.php file and download the excel file while staying on the index page, a jQuery script ...

PHP: Ways to combine the elements of this array?

Here is the code snippet I am working with: $arr = array($check); After executing this line: echo "<pre>"; die(print_r($arr)); The result displayed in Firebug is: <pre>Array ( [0] => Array ( [0] = ...

51% of memory being consumed by /ds_extras_node_page_view in Drupal 7

I've been dealing with a Drupal 7 website that experiences downtime a few times per month for about 4 to 5 minutes. According to the New Relic report, /ds_extras_node_page_view consumes 52% to 92% of the memory during loading, which is causing the sit ...

When the body contains a specific class, execute the following actions and so forth

Recently transitioned from working with Wordpress to Magento, and I am facing challenges in understanding a specific concept within Magento. I am unsure of how to achieve my goal using their API, which involves setting a variable based on the body class be ...

What sets apart codeigniter's controller and libraries?

During my interview today, I was presented with the question above by the interviewer. Now I'm curious - what is the correct response? ...

Guide to extracting name and email address from a string in PHP, with the option to use regular expressions

The text below contains a list of names and emails: "Test, User" < <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="582c3d2b2c182c3d2b2c763b373b">[email protected]</a> >, "Another, Test" < <a href="/cdn ...

Using PHPs nth-child in media queries

There are multiple images on MyPage, typically displayed in rows of 6. However, the number of images per row adjusts based on browser size using media queries. The issue arises with the margin set for the last image in each row, as the nth-child property r ...

Encountering an issue when attempting to save JSON data in the database: unable to convert object into a string

To summarize, my data is stored in Javascript: JSONdata = { name: form.name.value, address1: form.custa.value, address2: form.custa2.value, postcode: form.custpc.value, order: fullorder, cost: document.getElementById('total&ap ...

What methods can I use to conceal #! from showing on the browser's address bar?

Imagine you have the below link: www.someurl.com/#!?page=index How would you convert it into one of these options: www.someurl.com/#!/index (using mod_rewrite) www.someurl.com/ajax/index (also using mod_rewrite, but replacing #! with ajax) www.someurl. ...

Creating a Laravel development server without relying on php artisan is a straightforward process

I'm a Laravel beginner and I recently installed the Voyager admin panel for CRUD operations. The folder structure of my project is as follows: testadmin (project name) -> vendor -> tcg -> voyager When I run php artisan serve, I can access m ...

Unable to execute response

I'm facing an issue with a form in which I am utilizing jquery.ajax to execute PHP code in the background. Unfortunately, my JavaScript code isn't handling the response from the script properly. Interestingly, if I use if (status == "success"), ...

Is the code in adherence to Liskov's substitution principle?

Before upgrading to PHP5.4, I decided to test my current code and found that it no longer functions due to PHP tightening its inheritance model. In response to this, I have been studying SOLID, particularly focusing on Liskov's substitution principle ...

Having trouble transferring a variable between two PHP files?

On my login page, I have implemented a feature where if a user enters incorrect login information, an error message is displayed on the same page. The code for this functionality is spread across three different files - one for plain HTML, another containi ...