Bonjour, j'ai développé un site en PHP/MySQL sous MAMP (PHP 4).

Tout fonctionne bien sous PHP 4, et je viens d'essayer sur un PC (Vista) avec PHP 5.3.0 (WAMP), et là le site ne fonctionne pas.

Lorsque je charge http://localhost/, j'ai une erreur comme quoi Apache HTTP Server a cesser de fonctionner.

Voici le code source d'une page de test :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
define('SERVER','localhost');
define('BASE','ceric');
define('DB_USER','root');
define('DB_PASS','');
define('DB_PREFIX','ceric_');
 
function db_connexion($base = BASE){
	if(@mysql_connect(SERVER,DB_USER,DB_PASS)&& mysql_select_DB($base)){
		db_query("SET NAMES 'utf8'");
		return true;
	}
	else{
		header("HTTP/1.1 503 Service Unavailable");
		echo "Impossible de se connecter à la base <b>$base</b> : ".mysql_error();
		die();
	}
}
 
function db_query($requete){
	$requete	= str_replace('PREFIX_', DB_PREFIX, $requete);
	$resultat	= @mysql_query($requete) or die ("<p><b>Erreur SQL :</b><br/><code>".mysql_error()."</code><br/>
	<b>Requête :</b><br/><code>".$requete."</code></p>");
	if(mysql_errno()>0)
		return false;
	else
		return $resultat;
}
 
function db_close(){
	if(mysql_close())
		return true;
	else{
		echo 'Impossible de se déconnecter de la base';
		return false;
	}
}
 
global $message;
session_start();
 
db_connexion();
echo 'Test';
db_close();
?>
En cherchant un peu, je me suis aperçu que c'était la fonction mysql_close() qui pose problème. Si je met en commentaire la dernière ligne de code :

Et bien pas d'erreur, ça affiche Test dans mon navigateur.


Voici ce qui se passe dans le log apache :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[Thu Oct 22 16:21:56 2009] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations
[Thu Oct 22 16:21:56 2009] [notice] Server built: Dec 10 2008 00:10:06
[Thu Oct 22 16:21:56 2009] [notice] Parent: Created child process 2192
[Thu Oct 22 16:21:56 2009] [notice] Child 2192: Child process is running
[Thu Oct 22 16:21:56 2009] [notice] Child 2192: Acquired the start mutex.
[Thu Oct 22 16:21:56 2009] [notice] Child 2192: Starting 64 worker threads.
[Thu Oct 22 16:21:56 2009] [notice] Child 2192: Starting thread to listen on port 80.
 
[Thu Oct 22 16:22:29 2009] [notice] Parent: child process exited with status 255 -- Restarting.
[Thu Oct 22 16:22:29 2009] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations
[Thu Oct 22 16:22:29 2009] [notice] Server built: Dec 10 2008 00:10:06
[Thu Oct 22 16:22:29 2009] [notice] Parent: Created child process 5288
[Thu Oct 22 16:22:29 2009] [notice] Child 5288: Child process is running
[Thu Oct 22 16:22:29 2009] [notice] Child 5288: Acquired the start mutex.
[Thu Oct 22 16:22:29 2009] [notice] Child 5288: Starting 64 worker threads.
[Thu Oct 22 16:22:29 2009] [notice] Child 5288: Starting thread to listen on port 80.

J'y comprends rien, d'habitude quand quelque chose ne va pas en PHP, PHP affiche la raison du dysfonctionnement (Warning, Notice...)

Mais là rien, c'est carrément Apache qui plante !

Vous avez déjà eu le problème ? Est-ce spécifique à PHP 5.3.0 ?

Merci pour votre aide