Au secour !!!!

Petit nouveau ! | 4 Messages

22 mars 2007, 17:21

Bonjour, je me présente avant tout, Erick 34 ans , infographiste 3D.
J'ai besoin de vos conseil éclairé car la je suis un peut dans la mouise , je m'explique:

J'utilisais un script pour faire des pages de news sur un site en flash (http://www.componentsforflash.net/featuresNewsFeed.htm) , ca marchait nickel sur mon vieux serveur en PHP4..Mais j'ai du changer de serveur , la je suis en PHP 5.04.
quand je lance le script "install.php" j'obtiens ces erreurs :

Code : Tout sélectionner

Warning: Invalid argument supplied for foreach() in /var/www/vhosts/xxxx.fr/httpdocs/admin/scripts/actualite/install.php on line 22 Warning: Invalid argument supplied for foreach() in /var/www/vhosts/xxxx.fr/httpdocs/admin/scripts/actualite/install.php on line 23 Warning: Invalid argument supplied for foreach() in /var/www/vhosts/xxxx.fr/httpdocs/admin/scripts/actualite/install.php on line 24 Notice: Undefined variable: agree in /var/www/vhosts/xxxx.fr/httpdocs/admin/scripts/actualite/install.php on line 159
or voici les ligne 22,23,24 :
foreach($HTTP_GET_VARS as $name => $value) { $$name = $value;}
foreach($HTTP_POST_VARS as $name => $value) { $$name = $value;}
foreach($HTTP_COOKIE_VARS as $name => $value) { $$name = $value;}
et 159
else if ($agree!="yes")
Etant allergique au code , et franchement etant nul en language , allez y doucement ...lol

Merci pour votre secour :)

Erick

Petibidon en vadrouille
Invité n'ayant pas de compte PHPfrance

22 mars 2007, 17:41

hello,

les variables HTTP_*_VARS sont dépréciées et certaines configurations les désactivent.

il faut les remplacer par $_POST, $_GET, $_COOKIE

sinon pour ce que font les trois lignes que tu nous as présenté, tu devrais pouvoir les replacer par
extract( $_REQUEST );
et à priori tu obtiendras exactement le meme résultat.

Petit nouveau ! | 4 Messages

22 mars 2007, 17:52

heh meric petitbidon en vadrouille c gentil de me repondre si vite...

tu veux dire qu'il fo ce style de code ( ne coannaissant pas le code et les sytaxes PHP , je rique de d'écrire des barbarismes qui vont vous faire rire ):
foreach($_POST as $name => $value) { $$name = $value;} 
foreach($_GET as $name => $value) { $$name = $value;} 
foreach($_COOKIE as $name => $value) { $$name = $value;}

Par contre , la g rien capter
extract( $_REQUEST );
Merci tout de meme..ca avance...

Administrateur PHPfrance
Administrateur PHPfrance | 3131 Messages

22 mars 2007, 17:59

extract() extrait les clés d'un tableau et les transforme en variables selon leur valeur attribuée.
Clique sur le nom de la fonction pour avoir tous les détails.

petibidon en vadrouille
Invité n'ayant pas de compte PHPfrance

22 mars 2007, 18:03

exemple 1 : oui c'est exactement cela.

exemple 2 : exactement la meme chose que exemple 1, à ceci pres que ça fait qu'une ligne, donc plus intéressant pour les fainéants, et accessoirement si la fonction existe, c'est pas pour enfiler des perles :)

Petit nouveau ! | 4 Messages

22 mars 2007, 18:14

ok ca a marché..j'ai pu passer a l'etape suivante , celle ou il me demande de remplir les champs de connection a la base de données (nom, utilisateur, mot de passe) ..mais quand j'appuis sur le boutton CONFIRM , il me renvois sur une page blanche aavec ds le navigateur , comme url :

Code : Tout sélectionner

http://xxxx.fr/admin/scripts/actualite/<br%20/><b>Notice</b>:%20%20Undefined%20variable:%20PHP_SELF%20in%20<b>/var/www/vhosts/xxxx.fr/httpdocs/admin/scripts/actualite/install.php</b>%20on%20line%20<b>101</b><br%20/>?agree=yes
Donc je pense que c un soucis avec le message de la ligne 159 :(

En tout ca ca fait plaisir de voir une vraie communauté..si vous avez des soucis avec 3dsmax ou maya , je suis la pour vous tendre la main

Petit nouveau ! | 4 Messages

22 mars 2007, 18:19

et encore merci..je viens de tester avec la fonction extract, c nickel aussi..magique :)

voila le code de la page complet, si ca peut vous aider a m'aider :
(sachant que le code de la ligne 159 est en ligne 157 vu que sur le code , j'utilise la fonction " EXTRACT" , donc j'ai gagné 2 lignes
<html>
 <body bgcolor="#DDDDDD">
 <style>
<!--
p, td            { font-family: Verdana; font-size: 10pt }
.head            { font-family: Verdana; font-size: 10pt; font-weight:bold }
.small        { font-family: Verdana; font-size: 8pt }
-->
     </style>
	  <div align="center">
        <center>
	  <table style="border-collapse: collapse" bordercolor="#111111" cellspacing="1" width="75%" border="1">
	   <tr>
	    <td bgcolor="#748992">
        <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">Flash News Component  Ver 1.0 Installation</font></b></td>
	   </tr>
	   <tr>
	    <td bgcolor="#FFFFFF">

<?php

extract( $_REQUEST ); 

function message($str)
{
    ?>
	<span style="color: red"><p class="head">Stopping!</p> Encountered an error:</span><br/>
		<pre>
		<?=$str?>
		</pre>
	<?php
} 

if (isset($confirm))
{ 
////////////////////////////////
// Connect to Database
////////////////////////////////
	$conn=mysql_connect ($dbhost, $dbuser, $dbpass) or die ("<br><br><b>Failed! Unable to connect to database,  go back and check your database host, username and password.</b><br>Error:<br>". mysql_error());
	mysql_select_db ($dbname) or die ("<br><b>Failed! Unable to select database,  go back and check your database name.</b><br>Error:<br>". mysql_error());

////////////////////////////////
//Create Table
////////////////////////////////
echo "<p class=\"small\"><br>Inserting tables...</p>";

        $drop = "DROP TABLE IF EXISTS ". $dbtabel."";
	mysql_query($drop, $conn) or die(message(mysql_error()));
	$sql = "CREATE TABLE ". $dbtabel." (
		  	`newsID` int(11) NOT NULL auto_increment,
  			`title` varchar(100) default NULL,
  			`link` varchar(255) default NULL,
  			`posted` int(11) default NULL,
  			`body` mediumtext,
  			PRIMARY KEY  (`newsID`)
) TYPE=MyISAM COMMENT='newscomponent Table'";
	mysql_query($sql, $conn) or die(message(mysql_error()));
////////////////////////////////
/// Write config.php file
////////////////////////////////
chmod("inc/config.php", 0755);

	if (!$fp = fopen ("inc/config.php", w)) message ("Can't open config.php file for writing");
		$data= "<?php \n";
		$data.=  " \$dbhost = \"".$dbhost."\";\n";
		$data.= " \$dbname = \"".$dbname."\";\n";
		$data.= " \$dbuser = \"".$dbuser."\";\n";
		$data.= " \$dbpass = \"".$dbpass."\";\n";
		$data.= " \$dbtabel = \"".$dbtabel."\";\n?>";
	if (!$fw = fwrite($fp, $data, strlen($data))) message ("Error writing into config.php. Please set the filepremission of config.php to 755");
	fclose($fp);
	if ($fw) {echo "<p align=\"center\"><b><font size=\"4\">Installation Complete!</font></b></p>
			<p align=\"center\">You must now delete install.php file for security reasions.</p><br>"; exit();}
	else echo "Installation failed. Error writing config.php.";	
}

if (isset($submit))
	{
	$error = array();
	if (!$dbname) { $error [] = "Database Name has not been filled."; }
	if (!$dbhost) { $error [] = "Database Hostname has not been filled."; }
	if (!$dbuser) { $error [] = "Database Username has not been filled."; }
	if (!$dbpass) { $error [] = "Database Password has not been filled."; }
	if (!$dbtabel) { $error [] = "Tabel name has not been filled."; }
	
	if (count($error) == 0)
		{
///////////////////////
// CONFIRM
////////////////////////
		 $dbname = htmlentities ($_POST['dbname']); 
		 $dbhost = htmlentities ($_POST['dbhost']); 
		 $dbuser = htmlentities ($_POST['dbuser']); 
		 $dbpass = htmlentities ($_POST['dbpass']); 
		 $dbtabel = htmlentities ($_POST['dbtabel']); 
?>
     <p align="center"><br><b>Cofirm Settings</b><br>Please confirm your settings.</p>
	</b></p>
          <center><form method="POST" action="<?php echo "$PHP_SELF?agree=yes"; ?>" name="confirm">
          <table cellpadding="3" style="border-collapse: collapse" bordercolor="#111111" width="90%" id="AutoNumber1" cellspacing="0">
            <tr>
              <td colspan="3" align="center"><table width="50%"  border="0" cellspacing="0" cellpadding="0">
                <tr bordercolor="#111111">
                  <td width="50%" align="right">Database Name</td>
                  <td width="50%"><b><?php echo $dbname; ?></b></td>
                </tr>
                <tr bordercolor="#111111">
                  <td width="50%" align="right">Database Host</td>
                  <td width="50%"><b><?php echo $dbhost; ?></b></td>
                </tr>
                <tr bordercolor="#111111">
                  <td width="50%" align="right">Database Username</td>
                  <td width="50%"><b><?php echo $dbuser; ?></b></td>
                </tr>
                <tr bordercolor="#111111">
                  <td width="50%" align="right">Database Password</td>
                  <td width="50%"><b><?php echo $dbpass; ?></b></td>
                </tr>
                <tr>
                  <td width="50%" align="right" bordercolor="#111111">Tabel Name </td>
                  <td><b><?php echo $dbtabel; ?></b></td>
                </tr>
              </table></td>
              </tr>
            <tr>
              <td colspan="3" align="right">&nbsp;</td>
              </tr>
            <tr>
              <td colspan="3">
              <p align="center" class="small">
              <input type="submit" value="confirm" name="confirm" ><br>(Note: The installer will setup the tables in the next step.)</p>
	      <p align="center">No I've to make changes! Go <a href="javascript:history.go(-1)">back</a></p>
		</td>
            </tr>
            </table>
	<input type="hidden" name="dbname" value="<?php echo $dbname; ?>"> 
	<input type="hidden" name="dbuser" value="<?php echo $dbuser; ?>"> 
	<input type="hidden" name="dbpass" value="<?php echo $dbpass; ?>"> 
	<input type="hidden" name="dbhost" value="<?php echo $dbhost; ?>"> 
	<input type="hidden" name="dbtabel" value="<?php echo $dbtabel; ?>">
          </form>
          </center>
<?php
		}
	else 
		{
		 echo "<br><p class=\"head\">You've not filled in all database!<br/>\n";
		 echo "Here is what you mised:</p>\n";
		 echo "<ul>\n";
		 for ($i = 0; $i < count($error); $i++) {echo "<li>" . $error[$i] . "</li><br/>\n";} 
		 echo "</ul>\n";
		 echo "<p>Please go <a href=\"javascript:history.go(-1)\">back</a> and complete all details</p>\n";
		}

}

else if ($agree!="yes") 
	{
	?>
<br><br>
<p align="center"><b>Warning:</b> Run this script only if you're installing "NewsComponetForFlash" for the first time. The setup process will create new tables and overwrite any previous "NewsComponetForFlash" data.</p>
<p align="center"><b>NewsComponetForFlash License Agreement </b></p>
<p align="center"><em><font size="2">componentsforflash.net  is not to be held resposible for deleting data or in other ways harm content on you server.</font></em> </p>
<p align="center"><a href="?agree=yes">I Agree</a></p>
<br>	<?php 
	}

else 
 {
  if (file_exists("inc/config.php"))
	if (is_writeable("inc/config.php"))
	{
///////////////////
//DISPLAY FORM
///////////////////
	?>
 <div align="center"><b> Database Settings<br>
  </b><font size="1">If you're unaware of your database settings please ask your 
  webhost.</font> </div>
<div align="center"> 
  <center>
    <form method="POST" action=""$PHP_SELF?agree=yes"">
      <table border="0" cellpadding="3" style="border-collapse: collapse" bordercolor="#111111" width="90%" id="AutoNumber1" cellspacing="3">
        <tr> 
          <td width="45%" align="right">Database Name</td>
          <td width="45%"> <input type="text" name="dbname" size="20" ></td>
        </tr>
        <tr> 
          <td width="45%" align="right">Database Host</td>
          <td width="45%"> <input type="text" name="dbhost" size="20" value="localhost" ></td>
        </tr>
        <tr> 
          <td width="45%" align="right">Database Username</td>
          <td width="45%"> <input type="text" name="dbuser" size="20" ></td>
        </tr>
        <tr> 
          <td width="45%" align="right">Database Password</td>
          <td width="45%"> <input type="password" name="dbpass" size="20" ></td>
        </tr>
        <tr> 
          <td align="right">Tabel Name </td>
          <td align="left"><input type="text" name="dbtabel" size="20" value="mynews" ></td>
        </tr>
        <tr> 
          <td width="100%" style="font-family: Verdana; font-size: 10pt" colspan="2"> 
            <p align="center">
              <input type="submit" value="submit" name="submit" >
            </td>
        </tr>
        <tr> 
          <td colspan="2" align="right">   <p align="center"> 
          </td>
          </tr>
      </table>
    </form>
  </center>
</div>
<?php
///////////////////
//END DISPLAY FORM
///////////////////
	}
	else
	{
	echo ' <p align="center"><font color="#FF0000"><b>Error</b>:</font> <b>
        inc/config.php</b> is not writeable! Please CHMOD it to <b>666</b> or <b>777</b>.</p>';
	}
  else
 	 {
	  echo '
	   <p align="center"><font color="#FF0000"><b>Error</b>:</font> <b>
	          inc/config.php</b> is not FOUND! Please upload the file.</p>';
	  }
 }

function encrypt($string) {//hash then encrypt a string 
	$crypted = crypt(md5($string), md5($string)); 
	return $crypted; 
	} 

?>
 </tr>
	  </table>
	    </center>
      </div>
</body>
	</html>