Page 1 sur 1

probleme connexion base de donnée

Posté : 09 juil. 2010, 11:37
par chacha
bonjour,

j'ai un probleme de page web. enfaite j'utilise wamp et je souhaite avoir un site web en local. j'ai reussi a avoir toute les pages sauf une qui ne veut pas passer.
j'ai ce message d'erreur sur ma page web!

Warning: mysql_query() [function.mysql-query]: Access denied for user 'Système'@'localhost' (using password: NO) in C:\wamp\www\jpgtransaction\html\annonces.php on line 118

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\wamp\www\jpgtransaction\html\annonces.php on line 118
Erreur SQL !
SELECT * FROM CATEGORIE
Access denied for user 'Système'@'localhost' (using password: NO)

et le code de cette page qui affiche erreur est utilisé sur une autre page et marche correctement

include("../include/connexionBase.inc")
(cela se trouve avant le doctype)
<?php
					////////////////////////////////////////////////////////////////////////////////////////////////////
                    //combo liste des categories
					////////////////////////////////////////////////////////////////////////////////////////////////////
					$sq3 = 'SELECT * FROM CATEGORIE';

              		$req3 = mysql_query($sq3) or die('Erreur SQL !<br>'.$sq3.'<br>'.mysql_error());


					echo '<select  id="f_cat" tabindex="1" name="categorie" value='.isset( $_POST['categorie'] ).'>';
					//echo '<select  id="f_cat" tabindex="1" name="categorie" value='.isset( $_SESSION['categorie'] ).'>';

						echo '<option value="%">----------------------Toutes----------------------</option>';
						while ( $listcat = mysql_fetch_array( $req3 ) ) {

								echo '<option ';
              					if ($listcat['CAT_NOM']==@$_POST['categorie']){echo 'selected ';}
              					echo 'value="'.$listcat['CAT_NOM'].'">'.htmlentities($listcat['CAT_NOM']).'</option>';


 							//echo '<option value="'.$listcat['CAT_NOM'].'">'.$listcat['CAT_NOM'].'</option>';
						}
					//}
					//mysql_close();
					mysql_free_result($req3);
              		echo '</select>';
			?>
Quelqu'un serait-il pourquoi ?

Merci

Re: probleme connexion base de donnée

Posté : 09 juil. 2010, 11:53
par stealth35
tu fais pas de mysql_connect dans ton code

Re: probleme connexion base de donnée

Posté : 09 juil. 2010, 12:09
par chacha
si je le fais dans le fichier connexionBase que j'appelle avec le include

Re: probleme connexion base de donnée

Posté : 09 juil. 2010, 13:05
par stealth35
si je le fais dans le fichier connexionBase que j'appelle avec le include
dans ce que ta monter ca y est pas, montre ton connexionBase.inc

Re: probleme connexion base de donnée

Posté : 09 juil. 2010, 14:22
par chacha
voici le fichier
<?php
set_time_limit(0);
	
$host = "*******"; // Machine h�bergeant la base de donn�e
$user = "*******";  // Nom d'utilisateur = Nom de la base que vous avez choisi
$pass = "*******";      // Le mot de passe que vous avez choisi pour cette base
$base = "*******";  // Nom de la base de donn�e

$maConnexion=mysql_connect($host,$user,$pass) or die("Connexion : impossible de se connecter");
$maSelection=mysql_select_db($base) or die("Connexion : base de donn�es introuvable");


?>

Re: probleme connexion base de donnée

Posté : 09 juil. 2010, 14:29
par chacha
jai aussi essayer ca dans le head
<?php

set_time_limit(0);
	
$host = "*******"; // Machine hébergeant la base de donnée
$user = "*******";  // Nom d'utilisateur = Nom de la base que vous avez choisi
$pass = "*******";      // Le mot de passe que vous avez choisi pour cette base
$base = "*******";  // Nom de la base de donnée

function connexion_mysql_db() {
global $host,$login,$pass;
$db = mysql_connect($host,$login,$pass) or erreur_connexion_mysql();
mysql_select_db($base,$db);  
}

?>

Re: probleme connexion base de donnée

Posté : 09 juil. 2010, 14:35
par stealth35
montre le fichier entier sur lequel t'as une erreur

Re: probleme connexion base de donnée

Posté : 12 juil. 2010, 09:16
par chacha
<?php

include("../include/connexionBase.inc");

//=========================================

// includes du fichier fonctions
	require 'fonctions.php';
//=========================================

session_start();

/*
// si la connexion échoue
if ($maConnexion == false) {
	// on renvoie une variable resultat_0 qui indique l'échec
	// ainsi qu'une variable erreurmsg qui indique la raison de l'échec
	echo "&resultat_0=Echec&erreurmsg="; 
	echo utf8_encode("Connexion : base de donnees introuvable"); 
	exit;
	}
 else{echo utf8_encode("Connexion : base de donnees JPG TRANSACTION Ok");}*/
?>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<!--<meta name="identifier-url" content="http://www.jpg-transactions.com">-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="content-language" content="FR">
<title>JPG Transaction – commerce tabac bar restaurant, annonces fond de commerce, annonces vente fond de commerce</title>
<meta name="description" content="JPG transactions vous accompagne dans l’acquisition d’un bien immobilière : commerce tabac bar restaurant, annonces fond de commerce, annonces vente fond de commerce. Nos équipes d’experts sont toujours à l’écoute de vos besoins">
<meta name="keywords" content="commerce tabac bar restaurant, annonces fond de commerce, annonces vente fond de commerce">
<meta name="author" content="agence immobiliere nantes">
<meta name="copyright" content="www.jpg-transactions.com"> 
<meta NAME="ROBOTS" CONTENT="INDEX, FOLLOW, NOYDIR, NOODP, ALL">


<?php

set_time_limit(0);
	
$host = "*******"; // Machine hébergeant la base de donnée
$user = "*******";  // Nom d'utilisateur = Nom de la base que vous avez choisi
$pass = "*******";      // Le mot de passe que vous avez choisi pour cette base
$base = "*******";  // Nom de la base de donnée

function connexion_mysql_db() {
global $host,$login,$pass;
$db = mysql_connect($host,$login,$pass) or erreur_connexion_mysql();
mysql_select_db($base);  
}

?>

 
  <script language="JavaScript" type="text/JavaScript">
<!--
function OuvrePopup(page,largeur,hauteur,options) {
  var top=((screen.height-hauteur)/2)+50;
  var left=((screen.width-largeur)/2)+75;
  window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}

//-->
  </script>
   <!-- ------------------------- CHOIX FEUILLE DE STYLE EN FONCTION NAVIGATEUR ------------------------- -->  
	<script language="JavaScript">
		var name = navigator.appName
		// On appelle le nom du navigateur avec la Propriété appName
		// de l'objet navigator 

		if (name == "Microsoft Internet Explorer")
		style=("../include/style.css");
		else style=("../include/style2.css"); // sinon c'est mozilla 
		document.write('<link rel="stylesheet" type="text/css" href="'+style+'" media="screen" />');
		
	</script> 
	<script type="text/javascript" src="../include/swfobject.js"></script>
</head>

<body  bottommargin="0">
<div id="conteneur" >
								<!-- PARTIE GAUCHE MENU ET CONTACT -->
<div id="menu">
	<NOEMBED><a href="html/organisation.html">Organisation</a> | <a href="html/services.html">Services</a> | <a href="html/annonces.php">Annonces</a> | <a href="html/construction.html">References</a> | <a href="html/partenaires.html">Partenaires</a> | <a href="html/contacta.php">Contact Achat</a> | <a href="html/contactv.php">Contact Vente</a></noembed>
	<script type="text/javascript">
   	var so = new SWFObject("../swf/menu.swf", "menu", "182", "302", "8", "#ffffff", true);
	so.write("menu");
	</script>

	</div>
	<div id="contact">
		<img src="../img/acquisition_fond_de_commerce.gif" alt="acquisition fond de commerce" border="0" /></img>
	</div>
	<div id="photo_service">
		<img src="../img/fond_commerce.jpg" alt="fond de commerce" border="0" /></img>
	</div>
	
	<!-- CALQUE DE RECHERCHE DE BIEN -->
	<div id="fond_recherche">
			<div id="txt_cat">
				Cat&eacute;gories :
			</div>
			<div id="txt_dep">
				D&eacute;partements :
			</div>
			
<div id="formu">
			 <form name="formRecherche" method="post"  action="./annonces.php">
			<?php
					////////////////////////////////////////////////////////////////////////////////////////////////////
                    //combo liste des categories
					////////////////////////////////////////////////////////////////////////////////////////////////////
					$sq3 = 'SELECT * FROM jpgtr40_JPG.categorie';
					
              		$req3 = mysql_query($sq3) or die('Erreur SQL !<br>'.$sq3.'<br>'.mysql_error());
					
					
					echo '<select  id="f_cat" tabindex="1" name="categorie" value='.isset( $_POST['categorie'] ).'>'; 
					//echo '<select  id="f_cat" tabindex="1" name="categorie" value='.isset( $_SESSION['categorie'] ).'>'; 
													
						echo '<option value="%">----------------------Toutes----------------------</option>';
						while ( $listcat = mysql_fetch_array( $req3 ) ) {
						
								echo '<option ';
              					if ($listcat['CAT_NOM']==@$_POST['categorie']){echo 'selected ';}
              					echo 'value="'.$listcat['CAT_NOM'].'">'.htmlentities($listcat['CAT_NOM']).'</option>';					
						
						
 							//echo '<option value="'.$listcat['CAT_NOM'].'">'.$listcat['CAT_NOM'].'</option>';
						}
					//}
					//mysql_close();
					mysql_free_result($req3);
              		echo '</select>';
			?>
			
			</div>
			<div id="formu">
			<?php
					////////////////////////////////////////////////////////////////////////////////////////////////////
                    //combo liste des departements
					////////////////////////////////////////////////////////////////////////////////////////////////////
					$sq2 = 'SELECT * FROM jpgtr40_JPG.departement ORDER BY DEPT_NUM';
					
              		$req2 = mysql_query($sq2) or die('Erreur SQL !<br>'.$sq2.'<br>'.mysql_error());
					
					
					echo '<select  id="f_dept" tabindex="2" name="departement" value='.isset( $_POST['departement'] ).'>';
					
						echo '<option value="%">-----------------------Tous------------------------</option>';
						while ( $listDept = mysql_fetch_array( $req2 ) ) {
 							
							echo '<option ';
              					if ($listDept['DEPT_NUM']==@$_POST['departement']){echo 'selected ';}
              					echo 'value="'.$listDept['DEPT_NUM'].'">'.$listDept['DEPT_NUM'].'&nbsp;-&nbsp;'.htmlentities($listDept['DEPT_NOM']).'</option>';
							
						
						}
					mysql_free_result($req2);
              		echo '</select>';
			?>
			</div>
			 <input type="hidden" name="charger" value="<?php echo isset( $_POST['charger'] ); ?>">
			<div id="b_valider2">
				<input type="image" src="../img/b_valider2.gif"  onClick="charger.value='ok';submit();">
				
				
			</div>
			</form>



	</div>

	<!-- BLOC DE JEAN-CHRISTOPHE -->
	<?php
	if (isset( $_POST['charger'] )!='ok' and @$_GET['lien']!='ok')
	{
	?>
	<div id="txt_annonces">
	<p><b>L'agence immobilière à Nantes, JPG Transactions est à l'écoute de vos besoins et vous propose de consulter les annonces actuellement disponibles pour trouver votre fond de commerce dans les départements du Grand Ouest.
	Pour une recherche approfondie, utilisez l'outil de recherche ci-dessus vous permettant d'affiner votre choix par catégorie et par département.<br /><br />
	Ci-après découvrez toutes les annonces disponibles par type de fond de commerce.</b></p>
	<table align="center">
	<tr>
	<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/annonces-hotel-restaurant.html">Hotêl restaurant</a>
	</td>
	<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/annonces-hotel-bureau.html">Hôtel bureau</a>
	</td>
	</tr>
	<tr>
	<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/annonces-creperie.html">Creperie</a>
	</td>
	<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/annonces-pizzeria.html">Pizzeria</a>
	</td>
	</tr>
	<tr>
	<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/annonces-restaurant.html">Restaurant</a>
	</td>
	<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/annonces-bar-restaurant.html">Bar restaurant</a>
	</td>
	</tr>
	<tr>
	<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/annonces-bar-brasserie.html">Bar brasserie</a>
	</td>
	<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/annonces-bar-pmu.html">Bar PMU</a>
	</td>
	</tr>
	<tr>
	<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/annonces-bar.html">Bar</a>
	</td>
	<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/annonces-bar-tabac.html">Bar tabac</a>
	</td>
	</tr>
	<tr>
	<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/annonces-presse.html">Presse</a>
	</td>
	<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/annonces-tabac-presse.html">Tabac presse</a>
	</td>
	</tr>
	<tr>
	<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/annonces-murs-commerciaux.html">Murs commerciaux</a>
	</td>
	<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/annonces-pas-de-porte.html">Pas de porte</a>
	</td>
	</tr>
	<tr>	
	<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/annonces-pme---pmi.html">PME - PMI</a>
	</td>
	<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/annonces-fleuristes">Fleuristes</a>
	</td>
	</tr>
	<tr>	
	<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/annonces-habillement-et-chaussures.html">Habillement et chaussures</a>
	</td>
	<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/annonces-salon-de-coiffure">Salon de coiffure</a>
	</td>
	</tr>
	<tr>	
	<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/annonces-salon-esthetique.html">Salon d’esthetique</a>
	</td>
	<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/annonces-alimentation">Alimentation</a>
	</td>
	</tr>
	<tr>	
	<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/annonces-decoration.html">Décoration</a>
	</td>
	<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/annonces-bar-pub-discotheque">Bar Pub Discothèque</a>
	</td>
	</tr>

	</table>

	</div>
	<?php
    	}
	?>
	<!-- FIN DU BLOC DE JEAN-CHRISTOPHE -->
	
	
	<?php	
	//=========================================
	
	// initialisation des variables 
	
	//=========================================
	
	// on va afficher 3 résultats par page.
	
	$nombre = 100;  
	
	// si limite n'existe pas on l'initialise à zéro
	
	if (!isset($limite)) $limite = 0; 
	
	// on cherche le nom de la page.    
	
	$path_parts = pathinfo($_SERVER['PHP_SELF']);
	
	$page = $path_parts["basename"];




//SI LE BOUTON OK EST VALIDE///////////////////////////////////////////////////////
	if (isset( $_POST['charger'] )=='ok' or @$_GET['lien']=='ok')
    {
	 	//=========================================    

		// requête SQL qui compte le nombre total 

		// d'enregistrements dans la table.

		//=========================================
		
		if (@$_GET['lien']=='ok')
		{
			$categorie = htmlentities( $_GET['categorie'] );
			$departement = $_GET['departement'];
			/*echo "<div id='affiche_echo'>";
			echo"num venant du lien page : ";
			echo $departement;
			echo "<br>";
			echo $categorie;
			echo "</div>";*/
			$_POST['departement'] = $departement;
			$_POST['categorie'] = $categorie;
		}
		else
		{	
			$categorie = htmlentities( $_POST['categorie'] );
			$departement = $_POST['departement'];	
			/*echo "<div id='affiche_echo'>";
			echo"num venant du formulaire : ";
			echo $departement;
			echo "<br>";
			echo $categorie;
			echo "</div>";*/
		}
		
		$sql = "SELECT count(INFO_ID) FROM jpgtr40_JPG.INFORMATION";
		
		//if (isset( $_POST['categorie'] )<>""){$sql=$sql." WHERE INFORMATION.INFO_CAT LIKE '".$_POST['categorie']."'"; }
		//if (isset( $_POST['departement'] )<>""){$sql=$sql." AND INFORMATION.INFO_DEPT LIKE '".$_POST['departement']."'"; }
		if (isset( $categorie )<>""){$sql=$sql." WHERE INFORMATION.INFO_CAT LIKE '$categorie'"; }
		if (isset( $departement )<>""){$sql=$sql." AND INFORMATION.INFO_DEPT LIKE '$departement'"; }

		$req = mysql_query($sql)  or die ('Erreur : '.mysql_error() );
		$row = mysql_fetch_row($req);
		$total = $row[0];
   

		//=========================================
		
		// vérifier la validité de notre variable 
		
		// $limite;
		
		//=========================================
		
		$verifLimite= verifLimite($limite,$total,$nombre);
		
		// si la limite passée n'est pas valide on la remet à zéro
		
		if(!$verifLimite)  {
		
			$limite = 0;
		
		}
		//=========================================
		
		//Fonction pour decoder le texte en html 
		
		//=========================================
		
		function decoder($texte){
			$texte = utf8_decode($texte);
			$texte = stripslashes($texte);
			$texte = trim($texte);
			$texte = htmlentities($texte, ENT_QUOTES);
			$texte = strip_tags($texte);
			$texte = nl2br($texte);
			$texte = str_replace(">", ">", $texte);
			$texte = str_replace("<", "<", $texte);
			return $texte;
		}

		//=========================================
		
		// requête SQL qui ne prend que le nombre 
		
		// d'enregistrement necessaire à l'affichage.
		
		//=========================================

		// on crée la requête SQL
		
		$sql = 'SELECT * FROM jpgtr40_JPG.INFORMATION';
		//if (isset( $_POST['categorie'] )<>""){$sql=$sql." WHERE INFORMATION.INFO_CAT LIKE '".$_POST['categorie']."'"; }
		//if (isset( $_POST['departement'] )<>""){$sql=$sql." AND INFORMATION.INFO_DEPT LIKE '".$_POST['departement']."'"; }
		if (isset( $categorie )<>""){$sql=$sql." WHERE INFORMATION.INFO_CAT LIKE '$categorie'"; }
		if (isset( $departement )<>""){$sql=$sql." AND INFORMATION.INFO_DEPT LIKE '$departement'"; }
		
		//$sql=$sql." ORDER BY INFORMATION.INFO_CAT ASC LIMIT ".$limite.",".$nombre."";
		$sql=$sql." ORDER BY INFORMATION.INFO_CAT";
		
	
		// on envoie la requête
		$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
		


	// si on a récupéré un résultat on l'affiche.
	if($total) {
		$limitesuivante = $limite + $nombre;
		$limiteprecedente = $limite - $nombre;

	echo'<div id="resultat">';
	
		// nombre d'annonces correspondant aux critères
		echo '<table align="center" border = "0" ><tr>'."\n";
		echo '<td id="infoResult"><b>&nbsp;&nbsp;&nbsp;&nbsp;'.$total.'&nbsp;annonce(s) correspond(ent) aux critères sélectionnés</b></td>';
		//echo '<td id="infoResult"><b>&nbsp;&nbsp;&nbsp;&nbsp;'.$total.''if ($total<2){'&nbsp;annonce corresponds'}else{'&nbsp;annonces correspondent'}' aux critères sélectionnés</b></td>';
		echo '</tr></table><br>'."\n";
		
		// on fait une boucle qui va faire un tour pour chaque enregistrement
		while($data = mysql_fetch_assoc($req))
    	{
		$prix=$data['INFO_PRIX'];
		$affichPrix = number_format($prix,2,","," ");
    	// on affiche les informations de l'enregistrement en cours
    	echo'<table width="600" height="22" border="0" cellpadding="0" cellspacing="0">';
  			echo'<tr id="cadreht">';										
    			echo'<td id="nom_bien" align="left" colspan="1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>'.$data['INFO_CAT'].'</b></td>';
				//echo'<td id="nom_bien" align="left" colspan="1">|&nbsp;&nbsp;<b>'.$data['INFO_CAT'].'</b></td>';
				//echo'<td align="right" colspan="2">Dépt&nbsp;:&nbsp;'.$data['INFO_DEPT'].'&nbsp;|&nbsp;Prix&nbsp;:&nbsp;'.$data['INFO_PRIX'].' &euro; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>';
				echo'<td align="right" colspan="2">Dépt&nbsp;:&nbsp;'.$data['INFO_DEPT'].'&nbsp;|&nbsp;Réf&nbsp;:&nbsp;'.$data['INFO_ID'].'&nbsp;|&nbsp;Prix&nbsp;:&nbsp;'.$affichPrix.' &euro; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>';
			echo'</tr>';
  			echo'<tr>';
    			echo'<td colspan="4">';
					echo'<table width="100%" border="0" cellpadding="0" cellspacing="0">';
      					echo'<tr>';
        					echo'<td id="milieu" align="left"><br><div  style="margin-left:10px; margin-right:10px;font-size:12px;">'.(ucfirst(decoder($data['INFO_DESC']))).'</div><br></td>';
      					echo'</tr>';
    				echo'</table>';
				echo'</td>';
 		 echo'</tr>';
  		echo'<tr>';
    		echo'<td id="cadrebas" width="600" align="right" colspan="4"><a href ="contactref.php?id='.$data['INFO_ID'].'" ><b>NOUS CONTACTER</b></a> | <a href =javascript:OuvrePopup("detail.php?id='.$data['INFO_ID'].'",650,500,"menubar=no,scrollbars=no,statusbar=no") ><b>DETAILS</b></a></img>&nbsp;&nbsp;&nbsp;&nbsp;</td>';
 	 	echo'</tr>';
	echo'</table><br><br>';
    	}
		mysql_free_result($req);
		//=========================================    
		
		// si le nombre d'enregistrement à afficher 
		
		// est plus grand que $nombre 
		
		//=========================================
		
		//if($total > $nombre) {
		
			// affichage des liens vers les pages
		
			//affichePages($nombre,$page,$total);
		
			// affichage des boutons
		
			//displayNextPreviousButtons($limite,$total,$nombre,$page);
		
		//}

	
		//=========================================		
	


	echo'</div>';
	}
	else{
		echo'<div id="aucun_resultat">';
		echo'<b>Aucun resultat ne correspond à votre recherche</b>';
		echo'</div>';
	}
}
	
else{
	 echo'<div id="resultat2">'; 	
	 echo '<b>Sélectionnez une Catégorie, un Département.</b>';
	 echo'</div>';
}


		// on ferme la connexion à mysql
		mysql_close();

?> 
 

	
	<div id="fond">
		<!--<img src="../img/fond.gif" border="0" /></img>-->
		<div id="basPage">
		<table width="240px" border="0" cellpadding="0" cellspacing="0" align="center">
      		<tr>
        		<td align="center"><img src="../img/bas_de_page.gif" border="0" usemap="#Map" /></img></td>
      		</tr>
    	</table>
		<map name="Map" id="Map">
<area shape="rect" coords="219,3,360,26" href="#" alt="" /><area shape="rect" coords="365,4,486,26" href="admin.php" alt="" /><area shape="rect" coords="489,3,573,27" href="contacta.php" alt="" />
</map>
		
	</div>
	
	</div>
	<div id="liens2">
	<a href="../html/organisation.html">Organisation</a> | <a href="../html/services.html">Services</a> | <a href="../html/annonces.php">Annonces</a> | <a href="../html/references.html">References</a> | <a href="../html/partenaires.html">Partenaires</a> | <a href="../html/contacta.php">Contact Achat</a> | <a href="../html/contactv.php">Contact Vente</a> | <a href="../plan_du_site.html" title="Plan du site">Plan du site</a>
</div>
		
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-15840624-1");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>

Re: probleme connexion base de donnée

Posté : 12 juil. 2010, 10:10
par stealth35
met les balises [ php][/php] on verra mieux :wink:

Re: probleme connexion base de donnée

Posté : 12 juil. 2010, 11:04
par chacha
<?php

include("../include/connexionBase.inc");

//=========================================

// includes du fichier fonctions
require 'fonctions.php';
//=========================================

session_start();

/*
// si la connexion échoue
if ($maConnexion == false) {
// on renvoie une variable resultat_0 qui indique l'échec
// ainsi qu'une variable erreurmsg qui indique la raison de l'échec
echo "&resultat_0=Echec&erreurmsg=";
echo utf8_encode("Connexion : base de donnees introuvable");
exit;
}
else{echo utf8_encode("Connexion : base de donnees JPG TRANSACTION Ok");}*/
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<!--<meta name="identifier-url" content="http://www.jpg-transactions.com">-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="content-language" content="FR">
<title>JPG Transaction – commerce tabac bar restaurant, annonces fond de commerce, annonces vente fond de commerce</title>
<meta name="description" content="JPG transactions vous accompagne dans l’acquisition d’un bien immobilière : commerce tabac bar restaurant, annonces fond de commerce, annonces vente fond de commerce. Nos équipes d’experts sont toujours à l’écoute de vos besoins">
<meta name="keywords" content="commerce tabac bar restaurant, annonces fond de commerce, annonces vente fond de commerce">
<meta name="author" content="agence immobiliere nantes">
<meta name="copyright" content="www.jpg-transactions.com">
<meta NAME="ROBOTS" CONTENT="INDEX, FOLLOW, NOYDIR, NOODP, ALL">

<?php

set_time_limit(0);

$host = "*******"; // Machine hébergeant la base de donnée
$user = "*******"; // Nom d'utilisateur = Nom de la base que vous avez choisi
$pass = "*******"; // Le mot de passe que vous avez choisi pour cette base
$base = "*******"; // Nom de la base de donnée

function connexion_mysql_db() {
global $host,$login,$pass;
$db = mysql_connect($host,$login,$pass) or erreur_connexion_mysql();
mysql_select_db($base);
}

?>
<script language="JavaScript" type="text/JavaScript">
<!--
function OuvrePopup(page,largeur,hauteur,options) {
var top=((screen.height-hauteur)/2)+50;
var left=((screen.width-largeur)/2)+75;
window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}

//-->
</script>
<!-- ------------------------- CHOIX FEUILLE DE STYLE EN FONCTION NAVIGATEUR ------------------------- -->
<script language="JavaScript">
var name = navigator.appName
// On appelle le nom du navigateur avec la Propriété appName
// de l'objet navigator

if (name == "Microsoft Internet Explorer")
style=("../include/style.css");
else style=("../include/style2.css"); // sinon c'est mozilla
document.write('<link rel="stylesheet" type="text/css" href="'+style+'" media="screen" />');

</script>
<script type="text/javascript" src="../include/swfobject.js"></script>
</head>

<body bottommargin="0">
<div id="conteneur" >
<!-- PARTIE GAUCHE MENU ET CONTACT -->
<div id="menu">
<NOEMBED><a href="html/organisation.html">Organisation</a> | <a href="html/services.html">Services</a> | <a href="html/annonces.php">Annonces</a> | <a href="html/construction.html">References</a> | <a href="html/partenaires.html">Partenaires</a> | <a href="html/contacta.php">Contact Achat</a> | <a href="html/contactv.php">Contact Vente</a></noembed>
<script type="text/javascript">
var so = new SWFObject("../swf/menu.swf", "menu", "182", "302", "8", "#ffffff", true);
so.write("menu");
</script>

</div>
<div id="contact">
<img src="../img/acquisition_fond_de_commerce.gif" alt="acquisition fond de commerce" border="0" /></img>
</div>
<div id="photo_service">
<img src="../img/fond_commerce.jpg" alt="fond de commerce" border="0" /></img>
</div>

<!-- CALQUE DE RECHERCHE DE BIEN -->
<div id="fond_recherche">
<div id="txt_cat">
Cat&eacute;gories :
</div>
<div id="txt_dep">
D&eacute;partements :
</div>

<div id="formu">
<form name="formRecherche" method="post" action="./annonces.php">
<?php
////////////////////////////////////////////////////////////////////////////////////////////////////
//combo liste des categories
////////////////////////////////////////////////////////////////////////////////////////////////////
$sq3 = 'SELECT * FROM jpgtr40_JPG.categorie';

$req3 = mysql_query($sq3) or die('Erreur SQL !<br>'.$sq3.'<br>'.mysql_error());


echo '<select id="f_cat" tabindex="1" name="categorie" value='.isset( $_POST['categorie'] ).'>';
//echo '<select id="f_cat" tabindex="1" name="categorie" value='.isset( $_SESSION['categorie'] ).'>';

echo '<option value="%">----------------------Toutes----------------------</option>';
while ( $listcat = mysql_fetch_array( $req3 ) ) {

echo '<option ';
if ($listcat['CAT_NOM']==@$_POST['categorie']){echo 'selected ';}
echo 'value="'.$listcat['CAT_NOM'].'">'.htmlentities($listcat['CAT_NOM']).'</option>';


//echo '<option value="'.$listcat['CAT_NOM'].'">'.$listcat['CAT_NOM'].'</option>';
}
//}
//mysql_close();
mysql_free_result($req3);
echo '</select>';
?>
</div>
<div id="formu">
<?php
////////////////////////////////////////////////////////////////////////////////////////////////////
//combo liste des departements
////////////////////////////////////////////////////////////////////////////////////////////////////
$sq2 = 'SELECT * FROM jpgtr40_JPG.departement ORDER BY DEPT_NUM';

$req2 = mysql_query($sq2) or die('Erreur SQL !<br>'.$sq2.'<br>'.mysql_error());


echo '<select id="f_dept" tabindex="2" name="departement" value='.isset( $_POST['departement'] ).'>';

echo '<option value="%">-----------------------Tous------------------------</option>';
while ( $listDept = mysql_fetch_array( $req2 ) ) {

echo '<option ';
if ($listDept['DEPT_NUM']==@$_POST['departement']){echo 'selected ';}
echo 'value="'.$listDept['DEPT_NUM'].'">'.$listDept['DEPT_NUM'].'&nbsp;-&nbsp;'.htmlentities($listDept['DEPT_NOM']).'</option>';


}
mysql_free_result($req2);
echo '</select>';
?>
</div>
<input type="hidden" name="charger" value="<?php echo isset( $_POST['charger'] ); ?>">
<div id="b_valider2">
<input type="image" src="../img/b_valider2.gif" onClick="charger.value='ok';submit();">


</div>
</form>



</div>

<!-- BLOC DE JEAN-CHRISTOPHE -->
<?php
if (isset( $_POST['charger'] )!='ok' and @$_GET['lien']!='ok')
{
?>
<div id="txt_annonces">
<p><b>L'agence immobilière à Nantes, JPG Transactions est à l'écoute de vos besoins et vous propose de consulter les annonces actuellement disponibles pour trouver votre fond de commerce dans les départements du Grand Ouest.
Pour une recherche approfondie, utilisez l'outil de recherche ci-dessus vous permettant d'affiner votre choix par catégorie et par département.


Ci-après découvrez toutes les annonces disponibles par type de fond de commerce.</b></p>
<table align="center">
<tr>
<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/an ... tml">Hotêl restaurant</a>
</td>
<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/an ... tml">Hôtel bureau</a>
</td>
</tr>
<tr>
<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/an ... reperie</a>
</td>
<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/an ... izzeria</a>
</td>
</tr>
<tr>
<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/an ... taurant</a>
</td>
<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/an ... .html">Bar restaurant</a>
</td>
</tr>
<tr>
<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/an ... .html">Bar brasserie</a>
</td>
<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/an ... .html">Bar PMU</a>
</td>
</tr>
<tr>
<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/an ... ml">Bar</a>
</td>
<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/an ... .html">Bar tabac</a>
</td>
</tr>
<tr>
<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/an ... >Presse</a>
</td>
<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/an ... tml">Tabac presse</a>
</td>
</tr>
<tr>
<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/an ... html">Murs commerciaux</a>
</td>
<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/an ... .html">Pas de porte</a>
</td>
</tr>
<tr>
<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/an ... .html">PME - PMI</a>
</td>
<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/an ... uristes</a>
</td>
</tr>
<tr>
<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/an ... abillement et chaussures</a>
</td>
<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/an ... ure">Salon de coiffure</a>
</td>
</tr>
<tr>
<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/an ... tml">Salon d’esthetique</a>
</td>
<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/an ... ntation</a>
</td>
</tr>
<tr>
<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/an ... oration</a>
</td>
<td width="200px" align="center"><a href="http://www.jpg-transactions.com/html/an ... heque">Bar Pub Discothèque</a>
</td>
</tr>

</table>

</div>
<?php
}
?>
<!-- FIN DU BLOC DE JEAN-CHRISTOPHE -->

<?php
//=========================================

// initialisation des variables

//=========================================

// on va afficher 3 résultats par page.

$nombre = 100;

// si limite n'existe pas on l'initialise à zéro

if (!isset($limite)) $limite = 0;

// on cherche le nom de la page.

$path_parts = pathinfo($_SERVER['PHP_SELF']);

$page = $path_parts["basename"];




//SI LE BOUTON OK EST VALIDE///////////////////////////////////////////////////////
if (isset( $_POST['charger'] )=='ok' or @$_GET['lien']=='ok')
{
//=========================================

// requête SQL qui compte le nombre total

// d'enregistrements dans la table.

//=========================================

if (@$_GET['lien']=='ok')
{
$categorie = htmlentities( $_GET['categorie'] );
$departement = $_GET['departement'];
/*echo "<div id='affiche_echo'>";
echo"num venant du lien page : ";
echo $departement;
echo "<br>";
echo $categorie;
echo "</div>";*/
$_POST['departement'] = $departement;
$_POST['categorie'] = $categorie;
}
else
{
$categorie = htmlentities( $_POST['categorie'] );
$departement = $_POST['departement'];
/*echo "<div id='affiche_echo'>";
echo"num venant du formulaire : ";
echo $departement;
echo "<br>";
echo $categorie;
echo "</div>";*/
}

$sql = "SELECT count(INFO_ID) FROM jpgtr40_JPG.INFORMATION";

//if (isset( $_POST['categorie'] )<>""){$sql=$sql." WHERE INFORMATION.INFO_CAT LIKE '".$_POST['categorie']."'"; }
//if (isset( $_POST['departement'] )<>""){$sql=$sql." AND INFORMATION.INFO_DEPT LIKE '".$_POST['departement']."'"; }
if (isset( $categorie )<>""){$sql=$sql." WHERE INFORMATION.INFO_CAT LIKE '$categorie'"; }
if (isset( $departement )<>""){$sql=$sql." AND INFORMATION.INFO_DEPT LIKE '$departement'"; }

$req = mysql_query($sql) or die ('Erreur : '.mysql_error() );
$row = mysql_fetch_row($req);
$total = $row[0];


//=========================================

// vérifier la validité de notre variable

// $limite;

//=========================================

$verifLimite= verifLimite($limite,$total,$nombre);

// si la limite passée n'est pas valide on la remet à zéro

if(!$verifLimite) {

$limite = 0;

}
//=========================================

//Fonction pour decoder le texte en html

//=========================================

function decoder($texte){
$texte = utf8_decode($texte);
$texte = stripslashes($texte);
$texte = trim($texte);
$texte = htmlentities($texte, ENT_QUOTES);
$texte = strip_tags($texte);
$texte = nl2br($texte);
$texte = str_replace(">", ">", $texte);
$texte = str_replace("<", "<", $texte);
return $texte;
}

//=========================================

// requête SQL qui ne prend que le nombre

// d'enregistrement necessaire à l'affichage.

//=========================================

// on crée la requête SQL

$sql = 'SELECT * FROM jpgtr40_JPG.INFORMATION';
//if (isset( $_POST['categorie'] )<>""){$sql=$sql." WHERE INFORMATION.INFO_CAT LIKE '".$_POST['categorie']."'"; }
//if (isset( $_POST['departement'] )<>""){$sql=$sql." AND INFORMATION.INFO_DEPT LIKE '".$_POST['departement']."'"; }
if (isset( $categorie )<>""){$sql=$sql." WHERE INFORMATION.INFO_CAT LIKE '$categorie'"; }
if (isset( $departement )<>""){$sql=$sql." AND INFORMATION.INFO_DEPT LIKE '$departement'"; }

//$sql=$sql." ORDER BY INFORMATION.INFO_CAT ASC LIMIT ".$limite.",".$nombre."";
$sql=$sql." ORDER BY INFORMATION.INFO_CAT";


// on envoie la requête
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());



// si on a récupéré un résultat on l'affiche.
if($total) {
$limitesuivante = $limite + $nombre;
$limiteprecedente = $limite - $nombre;

echo'<div id="resultat">';

// nombre d'annonces correspondant aux critères
echo '<table align="center" border = "0" ><tr>'."\n";
echo '<td id="infoResult"><b>&nbsp;&nbsp;&nbsp;&nbsp;'.$total.'&nbsp;annonce(s) correspond(ent) aux critères sélectionnés</b></td>';
//echo '<td id="infoResult"><b>&nbsp;&nbsp;&nbsp;&nbsp;'.$total.''if ($total<2){'&nbsp;annonce corresponds'}else{'&nbsp;annonces correspondent'}' aux critères sélectionnés</b></td>';
echo '</tr></table><br>'."\n";

// on fait une boucle qui va faire un tour pour chaque enregistrement
while($data = mysql_fetch_assoc($req))
{
$prix=$data['INFO_PRIX'];
$affichPrix = number_format($prix,2,","," ");
// on affiche les informations de l'enregistrement en cours
echo'<table width="600" height="22" border="0" cellpadding="0" cellspacing="0">';
echo'<tr id="cadreht">';
echo'<td id="nom_bien" align="left" colspan="1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>'.$data['INFO_CAT'].'</b></td>';
//echo'<td id="nom_bien" align="left" colspan="1">|&nbsp;&nbsp;<b>'.$data['INFO_CAT'].'</b></td>';
//echo'<td align="right" colspan="2">Dépt&nbsp;:&nbsp;'.$data['INFO_DEPT'].'&nbsp;|&nbsp;Prix&nbsp;:&nbsp;'.$data['INFO_PRIX'].' &euro; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>';
echo'<td align="right" colspan="2">Dépt&nbsp;:&nbsp;'.$data['INFO_DEPT'].'&nbsp;|&nbsp;Réf&nbsp;:&nbsp;'.$data['INFO_ID'].'&nbsp;|&nbsp;Prix&nbsp;:&nbsp;'.$affichPrix.' &euro; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>';
echo'</tr>';
echo'<tr>';
echo'<td colspan="4">';
echo'<table width="100%" border="0" cellpadding="0" cellspacing="0">';
echo'<tr>';
echo'<td id="milieu" align="left"><br><div style="margin-left:10px; margin-right:10px;font-size:12px;">'.(ucfirst(decoder($data['INFO_DESC']))).'</div><br></td>';
echo'</tr>';
echo'</table>';
echo'</td>';
echo'</tr>';
echo'<tr>';
echo'<td id="cadrebas" width="600" align="right" colspan="4"><a href ="contactref.php?id='.$data['INFO_ID'].'" ><b>NOUS CONTACTER</b></a> | <a href =javascript:OuvrePopup("detail.php?id='.$data['INFO_ID'].'",650,500,"menubar=no,scrollbars=no,statusbar=no") ><b>DETAILS</b></a></img>&nbsp;&nbsp;&nbsp;&nbsp;</td>';
echo'</tr>';
echo'</table><br><br>';
}
mysql_free_result($req);
//=========================================

// si le nombre d'enregistrement à afficher

// est plus grand que $nombre

//=========================================

//if($total > $nombre) {

// affichage des liens vers les pages

//affichePages($nombre,$page,$total);

// affichage des boutons

//displayNextPreviousButtons($limite,$total,$nombre,$page);

//}


//=========================================



echo'</div>';
}
else{
echo'<div id="aucun_resultat">';
echo'<b>Aucun resultat ne correspond à votre recherche</b>';
echo'</div>';
}
}

else{
echo'<div id="resultat2">';
echo '<b>Sélectionnez une Catégorie, un Département.</b>';
echo'</div>';
}


// on ferme la connexion à mysql
mysql_close();

?>

<div id="fond">
<!--<img src="../img/fond.gif" border="0" /></img>-->
<div id="basPage">
<table width="240px" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td align="center"><img src="../img/bas_de_page.gif" border="0" usemap="#Map" /></img></td>
</tr>
</table>
<map name="Map" id="Map">
<area shape="rect" coords="219,3,360,26" href="#" alt="" /><area shape="rect" coords="365,4,486,26" href="admin.php" alt="" /><area shape="rect" coords="489,3,573,27" href="contacta.php" alt="" />
</map>

</div>

</div>
<div id="liens2">
<a href="../html/organisation.html">Organisation</a> | <a href="../html/services.html">Services</a> | <a href="../html/annonces.php">Annonces</a> | <a href="../html/references.html">References</a> | <a href="../html/partenaires.html">Partenaires</a> | <a href="../html/contacta.php">Contact Achat</a> | <a href="../html/contactv.php">Contact Vente</a> | <a href="../plan_du_site.html" title="Plan du site">Plan du site</a>
</div>

</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-15840624-1");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>

Re: probleme connexion base de donnée

Posté : 12 juil. 2010, 11:05
par stealth35
autour de tout sinon c'est pire :mrgreen: