demande d'aide sur un script

Rabolo_
Invité n'ayant pas de compte PHPfrance

22 sept. 2011, 17:16

Bonjour,
Reconverti récemment dans le domaine du net, je m'adresse vers vous les experts suite à un souci sur un script fait maison (avec l'aide d'un ami) il y a maintenant plusieurs année.
Le script devais permettre d'aller chercher et afficher un id mais voilà ça marche pas.
En plus je voulais également allez chercher une autre table et afficher comment je peux incruster dans le script.
Je suis novice en php et je ne sais pas comment me prendre merci de votre aide
<?php
$url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$the_domain = parse_url($url, PHP_URL_HOST);
$the_domain = str_replace('www.', '', $the_domain);
?>
if(!empty($the_domain))
{
//on fait la connection à la base de données
$conn = mysql_connect('serveur','identifient','mdp');
mysql_select_db('base');
if(!$conn)
{
die('Impossible de se connecter à la base de données: ' . mysql_error());
}

// on regarde si l'url existe dans la base, et on récupère le ad_client si il existe

echo $the_domain;
$rez = mysql_fetch_array(mysql_query("SELECT ad_client FROM client WHERE url LIKE '%$url'"), MYSQL_NUM);
// Si oui, on déclare la variable ad_id avec l'id correspondant
if($the_domain != 'rabolo.com' && $the_domain != '')
{
//ici on met l'id
$g_id = $rez[0];

}
elseif($the_domain == 'rabolo.')
{
echo "the_domain = rabolo.com - On affiche id rabolo.com !!! !!";
//ici on met ton id
$g_id = '0517';
}
}
else
{
echo "the_domain=rabolo.com-On affiche id rabolo
//ici on met ton id
$g_id = '0517';
}
?>
<div><?php echo $g_id ?></div>
merci d'avance

Avatar du membre
Modérateur PHPfrance
Modérateur PHPfrance | 8758 Messages

23 sept. 2011, 00:23

Salut,

C'est vraiment pas clair ton affaire.

Je te conseil de faire un tour sur http://www.phpdebutant.org ou http://www.lephpfacile.com pour ce qui est du Sql je te conseil http://sqlpro.developpez.com


Avec des explications plus claire sur ton soucis on pourra peut etre t'aider


@+
Il en faut peu pour être heureux ......

Mammouth du PHP | 2278 Messages

25 sept. 2011, 09:10

Bonjour,
Dans cet état, le script affiche tout simplement la fin du code php.
<?php
$url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$the_domain = parse_url($url, PHP_URL_HOST);
$the_domain = str_replace('www.', '', $the_domain);
?> // EN TROP

if(!empty($the_domain)) // if (($the_domain != 'rabolo.com' ) && ($the_domain != '')) (1)
{
    //on fait la connection à la base de données
    $conn = mysql_connect('serveur','identifient','mdp');
    mysql_select_db('base');
  if(!$conn)
  {
    die('Impossible de se connecter à la base de données: ' . mysql_error());
  }

  // on regarde si l'url existe dans la base, et on récupère le ad_client si il existe

  echo $the_domain;
// il vaudrait mieux procéder en plusieurs temps :
//  $resultat = mysql_queyry ("SELECT ad_client FROM client WHERE url LIKE '%$url'");
 // if ($resultat)
 // {
 // $rez = mysql_fetch_array($resultat, MYSQL_NUM);
 //}
  // Si oui, on affecte à la variable ad_id  l'id trouvé dans la BDD
  if($the_domain != 'rabolo.com' && $the_domain != '') 
  // la deuxième partie du test est inutile. Je me demande même si on ne pourrait pas supprimer ce if et changer le test de début.
  // Pourquoi interroger la BDD quand il n'y a pas de nom de domaine et quand le domaine est connu comme rabolo.com ?

  {
  //ici on met l'id. 
  $g_id = $rez[0];
  }
  elseif($the_domain == 'rabolo.')
 {
   echo "the_domain = rabolo.com - On affiche id rabolo.com !!! !!";
//ici on met ton id
$g_id = '0517';
}
}
else
{
echo "the_domain=rabolo.com-On affiche id rabolo[b]";[/b]
//ici on met ton id
$g_id = '0517';
}
?>
<div><?php echo $g_id ?></div>
(1)_____________________________________________
if (($the_domain != 'rabolo.com' ) && ($the_domain != '')) //(1)if (($the_domain != 'rabolo.com' ) && ($the_domain != '')) //(1)
{
//consulttaion de la BDD... 
}
elseif ($the_domain== 'rabolo.com')
{

}
{
//consulttaion de la BDD... 
}
elseif ($the_domain== 'rabolo.com')
{

}
merci d'avance[/quote]
Vanitas vanitatum et omnia vanitas
Mes derniers livres :
Sauvez les Mots chez BoD,
Tous les chemins mènent à ROM chez BoD

Petit nouveau ! | 3 Messages

25 sept. 2011, 13:16

merci de sirakawa,
je ne sais ou sa merde mais ça ne marche pas. je doute sur ma table voici un extrait, tu me dire si tu voie une erreur

Champ | Type | interclassement | Attributs| Null | défault |Extra
ad_id | int(11) | | | non | | auto_increment
ad_client |varchar(256) |latin1_general_ci| | non | |
url | varchar(256)| latin1_general_ci | | non | |

merci

Mammouth du PHP | 2278 Messages

25 sept. 2011, 13:48

Tout au début mets :
print_r($_SERVER);
pour voir si tu obtiens la valeur que tu attends...
Pour l'instant j'ai faim....
Vanitas vanitatum et omnia vanitas
Mes derniers livres :
Sauvez les Mots chez BoD,
Tous les chemins mènent à ROM chez BoD

Petit nouveau ! | 3 Messages

25 sept. 2011, 19:13

j'obtiens des valeurs mes pas ce que je cherche !! :(