Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1549 connectés 

  FORUM HardWare.fr
  Programmation
  PHP

  Php ne renvoi rien au navigateur

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Php ne renvoi rien au navigateur

n°1468172
Rapha222
Posté le 31-10-2006 à 14:04:10  profilanswer
 

Salut,  
Je suis en train d'essayer ajax et j'ai un gros problème : php ne revoie rien au navigateur, même pas les balises HTML (voir cette page)
 
Voici mon code :

Code :
  1. <?php
  2.         require('../includes/config.php');
  3.         // On se connecte a la base de données
  4.         mysql_connect($config->db_host, $config->db_user, $config->db_password);
  5.         mysql_select_db($config->db_name);
  6.         // On fait une requete à la BDD si c'est le module de MAP pour avoir les informations du miniplofil
  7.         $retour = mysql_query('SELECT * FROM "phpore_users" WHERE id = "'.$_GET['id'].'" and password = "'.$_GET['pass'].'"');
  8.         $miniprofil = mysql_fetch_array($retour);
  9.         // On prépare xajax et on enregistre les fonctions  
  10.                
  11.         function goldards() // Fonction qui affiche les nombre d'argent  
  12.         {
  13.                 $reponse = new xajaxResponse();
  14.                 $goldards = '<span class="goldard">'.$miniprofil['goldard'].'</span><img src="../img/goldard.png" />';
  15.                 $reponse->addAssign("goldards","innerHTML",$goldards);
  16.                 return $reponse->getXML();
  17.         }
  18.        
  19.         function hp() // Fonction qui affiche le nombre de HP et calcule un tableau qui la représente
  20.         {
  21.                 $reponse = new xajaxResponse();
  22.                 $hp_on = $miniprofil['hp_max'] / $miniprofil['hp'];
  23.                 $hp_on = floor($hp_on * 75);
  24.                 $hp_off = 150 - $hp_on;
  25.                 $hp = '<table width="280" border="0" cellpadding="0" cellspacing="0">
  26.             <tr>
  27.         <td width="35">HP : </td>
  28.         <td width="'.$hp_on.'" background="templates/default/images/hp_on.png"></td>
  29.         <td width="'.$hp_off.'" background="templates/default/images/hp_off.png"></td>
  30.         <td width="95" align="right">'.$miniprofil['hp'].'/'.$miniprofil['hp_max'].'</td>
  31.         </tr></table>';
  32.         $reponse->addAssign("hp","innerHTML",$hp);
  33.         return $reponse->getXML();
  34.         }
  35. require ('../xajax_0.2.4/xajax.inc.php');
  36. $xajax = new xajax();
  37. $xajax->registerFunction("goldards" );
  38. $xajax->registerFunction("hp" );
  39. $xajax->processRequests();
  40. ?>
  41. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  42. <html xmlns="http://www.w3.org/1999/xhtml">
  43. <head>
  44. <script type="text/javascript">
  45. <!--
  46. // <![CDATA[
  47. function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
  48.   {
  49.   for(var i=0; i<document.images.length; i++)
  50.      {
  51.           var img = document.images[i]
  52.           var imgName = img.src.toUpperCase()
  53.           if (imgName.substring(imgName.length-3, imgName.length) == "PNG" )
  54.              {
  55.                  var imgID = (img.id) ? "id='" + img.id + "' " : ""
  56.                  var imgClass = (img.className) ? "class='" + img.className + "' " : ""
  57.                  var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
  58.                  var imgStyle = "display:inline-block;" + img.style.cssText
  59.                  if (img.align == "left" ) imgStyle = "float:left;" + imgStyle
  60.                  if (img.align == "right" ) imgStyle = "float:right;" + imgStyle
  61.                  if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle             
  62.                  var strNewHTML = "<span " + imgID + imgClass + imgTitle
  63.                  + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
  64.              + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
  65.                  + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
  66.                  img.outerHTML = strNewHTML
  67.                  i = i-1
  68.              }
  69.      }
  70.   }
  71. window.attachEvent("onload", correctPNG);
  72. //  ]]>
  73. -->
  74. </script>
  75. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  76. <title>Miniprofil</title>
  77. <style type="text/css">
  78. <!--
  79. body {
  80.         background-color: #5E5E5E;
  81. }
  82. body,td,th {
  83.         font-family: Geneva, Arial, Helvetica, sans-serif;
  84.         color: #B0B0B0;
  85. }
  86. a:link {
  87.         color: #B0B0B0;
  88.         text-decoration: underline;
  89. }
  90. a:visited {
  91.         text-decoration: underline;
  92.         color: #B0B0B0;
  93. }
  94. a:hover {
  95.         text-decoration: none;
  96.         color: #B0B0B0;
  97. }
  98. a:active {
  99.         text-decoration: underline;
  100.         color: #B0B0B0;
  101. }
  102. .goldard {
  103. font-size:24px;
  104.         color: #F8A345;
  105. }
  106. -->
  107. </style>
  108. <?php echo $xajax->printJavascript('../xajax_0.2.4/'); ?>
  109. <script>
  110. function refresh()
  111. {
  112.         xajax_hp();
  113.         setTimeout("refresh()", 5000);
  114.                 xajax_goldards();
  115.         setTimeout("refresh()", 5000);
  116. }
  117. </script>
  118. </head>
  119. <body>
  120. <div id="goldards"></div>
  121. <div id="hp"></div>
  122. </body>
  123. </html>


 
Savez vous où j'ai fais une erreur ?
 
Voila l'arborescence des dossiers :
Racine
|-xajax_0.2.4
|-modules
--|-ce fichier
|-includes
--|-config.php
 
Merci  ;)

mood
Publicité
Posté le 31-10-2006 à 14:04:10  profilanswer
 

n°1468209
teufeur2le​st
Posté le 31-10-2006 à 14:50:12  profilanswer
 

Salut !
 
essaye une fois de tout mettre en commentaire et de n'afficher que la ligne suivante : <?php echo phpinfo(); ?>
si rien ne s'affiche il faut te demander si tes pages sont bien sur un serveur...

n°1468250
Rapha222
Posté le 31-10-2006 à 15:20:08  profilanswer
 

si ca marche avec des autres scripts, j'ai essayé;
Mais je pense avoir trouvé le problème, il vient de la connexion a la BDD, le chemin pour le fichier config n'est pas valide.
Mais j'ai un autre problème, la j'ai tout mon code HTML qui s'affiche mais le contenu qui doit se mettre dans les balises div dédiées a ajax ne s'affiche pas par contre si je fait une bete echo de ces variables ca s'affiche.
 
Merci

n°1468401
Rapha222
Posté le 31-10-2006 à 17:39:35  profilanswer
 

Donc j'ai un problème avec ajax, le html est affiché cette fois ci mais ajax ne met pas le contenu dans les balises div avec l'id correspondant. Voici le code :

Code :
  1. <?php
  2. mysql_connect("localhost", "masterpocket", "****" );
  3. mysql_select_db("masterpocket_rpg" );
  4. // On fait une requete à la BDD si c'est le module de MAP pour avoir les informations du miniplofil
  5. $retour = mysql_query('SELECT * FROM phpore_users WHERE id="'.$_GET['id'].'"');
  6. $miniprofil = mysql_fetch_array($retour);
  7. // On prépare xajax et on enregistre les fonctions
  8. function goldards() // Fonction qui affiche les nombre d'argent
  9. {
  10.  $goldards = '<span class="goldard">'.$miniprofil['goldard'].'</span><img src="../img/goldard.png" />';
  11.  $reponse = new xajaxResponse();
  12.  $reponse->addAssign("goldards","innerHTML",$goldards);
  13.  return $reponse->getXML();
  14. }
  15. function hp() // Fonction qui affiche le nombre de HP et calcule un tableau qui la représente
  16. {
  17.  $hp_on = $miniprofil['hp_max'] / $miniprofil['hp'];
  18.  $hp_on = floor($hp_on * 75);
  19.  $hp_off = 150 - $hp_on;
  20.  $hp = '<table width="280" border="0" cellpadding="0" cellspacing="0">
  21.     <tr>
  22.         <td width="35">HP : </td>
  23.         <td width="'.$hp_on.'" background="templates/default/images/hp_on.png"></td>
  24.         <td width="'.$hp_off.'" background="templates/default/images/hp_off.png"></td>
  25.         <td width="95" align="right">'.$miniprofil['hp'].'/'.$miniprofil['hp_max'].'</td>
  26.         </tr></table>';
  27.      $reponsehp = new xajaxResponse();
  28.  $reponsehp->addAssign("tableau_hp","innerHTML",$hp);
  29.      return $reponsehp->getXML();
  30. }
  31. require ('../xajax_0.2.4/xajax.inc.php');
  32. $xajax = new xajax();
  33. $xajax->registerFunction("goldards" );
  34. $xajax->registerFunction("hp" );
  35. $xajax->processRequests();
  36. ?>
  37. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  38. <html xmlns="http://www.w3.org/1999/xhtml">
  39. <head>
  40. <script type="text/javascript">
  41. <!--
  42. // <![CDATA[
  43. function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
  44.   {
  45.   for(var i=0; i<document.images.length; i++)
  46.      {
  47.           var img = document.images[i]
  48.           var imgName = img.src.toUpperCase()
  49.           if (imgName.substring(imgName.length-3, imgName.length) == "PNG" )
  50.              {
  51.                  var imgID = (img.id) ? "id='" + img.id + "' " : ""
  52.                  var imgClass = (img.className) ? "class='" + img.className + "' " : ""
  53.                  var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
  54.                  var imgStyle = "display:inline-block;" + img.style.cssText
  55.                  if (img.align == "left" ) imgStyle = "float:left;" + imgStyle
  56.                  if (img.align == "right" ) imgStyle = "float:right;" + imgStyle
  57.                  if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle             
  58.                  var strNewHTML = "<span " + imgID + imgClass + imgTitle
  59.                  + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
  60.              + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
  61.                  + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
  62.                  img.outerHTML = strNewHTML
  63.                  i = i-1
  64.              }
  65.      }
  66.   }
  67. window.attachEvent("onload", correctPNG);
  68. //  ]]>
  69. -->
  70. </script>
  71. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  72. <title>Miniprofil</title>
  73. <style type="text/css">
  74. <!--
  75. body {
  76. background-color: #5E5E5E;
  77. }
  78. body,td,th {
  79. font-family: Geneva, Arial, Helvetica, sans-serif;
  80. color: #B0B0B0;
  81. }
  82. a:link {
  83. color: #B0B0B0;
  84. text-decoration: underline;
  85. }
  86. a:visited {
  87. text-decoration: underline;
  88. color: #B0B0B0;
  89. }
  90. a:hover {
  91. text-decoration: none;
  92. color: #B0B0B0;
  93. }
  94. a:active {
  95. text-decoration: underline;
  96. color: #B0B0B0;
  97. }
  98. .goldard {
  99. font-size:24px;
  100. color: #F8A345;
  101. }
  102. -->
  103. </style>
  104. <?php $xajax->printJavascript('../xajax_0.2.4/'); ?>
  105. <script>
  106. function refresh()
  107. {
  108.         xajax_hp();
  109.         setTimeout("refresh()", 5000);
  110.  xajax_goldards();
  111.         setTimeout("refresh()", 5000);
  112. }
  113. </script>
  114. </head>
  115. <body>
  116. <div id="goldards">
  117. </div>
  118. <div id="tableau_hp">
  119. </div>
  120. </body>
  121. </html>

 

C'est cette page-ci : http://goldswords.com/phpore/modul [...] l.php?id=2

 

Aidez moi svp  :cry:

 

J'ai pensé que c'était à cause de php qui envoyait quelque chose au navigateur avant le doctype, mais la je vois rien  :pfff:

 

Merci  ;)  


Message édité par Rapha222 le 13-11-2007 à 22:10:01
n°1468566
gatsu35
Blablaté par Harko
Posté le 01-11-2006 à 09:48:31  profilanswer
 

Ca sent le truc super mal codé dans lequel on pourrait facilement tricher


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  PHP

  Php ne renvoi rien au navigateur

 

Sujets relatifs
Adapter ce code pour une page PHP POPUP avec PHP probleme de ID
[PHP]Probleme requete insert[PHP] passer un array dans l'URL pour inclure des pages en pseudo-fram
[PHP]Probleme lien a href[PHP/Ajax/XSL/CSS/Etc] Explorateur Web
Coder une fonction recherche en PHP[PHP] Pagination
Quelques questions au sujet de Php /Perl / CGI...Cherche un site d'admin PHP pour uploader
Plus de sujets relatifs à : Php ne renvoi rien au navigateur


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR