I have trouble with Apache, which restarting, when I wish to open PHP code in browser. Code :

require_once 'DB.php';
PEAR::setErrorHandling(PEAR_ERROR_DIE);

$db_host = 'localhost';
$db_user = 'root';
$db_pass = 'marylover';
$db_name = 'test';
$dsn = "mysql://$db_user:$db_pass@unix+$db_host/$db_name";
$db = DB::connect($dsn);

It's crashes around the last line -> cannot connect with MySQL, I believe. I wish to use PEAR and Apache, however it appears they do not like one another. Assist me to, please! Thanks.

Whenever you say:

It's crashes around the last line -> cannot connect with MySQL, I believe. I wish to use PEAR and Apache, however it appears they do not like one another. Assist me to, please! Thanks.

I am presuming you mean in the PHP level (ie your script quits, there's no "crash" in the webserver level)?

The build of PHP getting used with Apache is probably likely to be dissimilar to what you are using together with your IDE (phpDesigner). The mysql extension within the PHP build getting used with Apache might be attempting to connect with MySQL in a different way (for instance using a socket file that doesn't exist).

Unless of course I have misinterpreted, it might appear the script is exiting since it can't connect with the database server.

This line appears like it might cause this to occur:

PEAR::setErrorHandling(PEAR_ERROR_DIE);

You should attempt running some sample code to ascertain if the mistake lies with creating an association to MySQL:

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$conn = mysql_connect('localhost', 'root', 'marylover');
mysql_select_db('test', $conn);

Also look at your configure command via phpinfo() and find out if either of the PHP build's continues to be put together using the --with-mysql-sock option