bonjour,
j'essaye de faire un petit jeu en java script, dans une de mes page j'écris un code en java script avec du PHP, et tout marche bien sur firefox mais dés que j'essaye avec internet explorer certaines variables PHP ne s'affichent :
Voici mon code PHP:
<?php
include("connect.php" );
$id=$_POST['idnv'];
$sql=sprintf("SELECT * FROM `niveaux` WHERE `id`='%s' ",mysql_real_escape_string($id));
$select = @mysql_query($sql);
$it=mysql_fetch_array($select,MYSQL_NUM);
$nom=$it[1];
$auteur=$it[2];
$niveau=$it[3];
$diff=$it[4];
$commentaire=$it[5];
$aide=$it[6];
$lennm=strlen($nom);
$lenau=strlen($auteur);
$lendf=strlen($diff);
$tabniveau=explode(",",$niveau);
echo("\n\t\t<SCRIPT laguage=\"javascript\">\nvar tabnv=[ " );
for($i=1;$i<=20;$i++)
{
echo("[" );
for($j=1;$j<=20;$j++)
{
$val=$tabniveau[($i-1)+20*($j-1)];
if ($j!=20)
echo("'{$val}'," );
else
echo("'{$val}'" );
if($val=="0b" )
{
$xs=$i-1;$ys=$j-1;
$sd=1;
}
else if($val=="0d" )
{
$xs=$i-1;$ys=$j-1;
$sd=0;
}
else if($val=="0g" )
{
$xs=$i-1;$ys=$j-1;
$sd=2;
}
else if($val=="0h" )
{
$xs=$i-1;$ys=$j-1;
$sd=3;
}
if($val=="1" )
{
$xh=$i-1;
$yh=$j-1;
}
}
echo("],\n " );
}
echo("];" );
echo("\n\t\tvar xs=$xs;var ys=$ys;\n\t\tvar sd=$sd;\n\t\tvar xh=$xh;var yh=$yh;" );
echo("\n\t\t</SCRIPT>\n" );
?>
je charge ma chaine de caractère depuis la base de donnée, que je transforme en matrice java script.
Puis je retiens certaine position qui m'intéressent que je retient dans des variable java script
Voici le code source que ce code génère lorsque j'ouvre la page avec firefox:
<SCRIPT laguage="javascript">
var tabnv=[ ['3','3','3','3','3','3','3','3','3','3','3','3','3','3','3','3','3','3','3','3'],
['3','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','3'],
['3','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','3'],
['3','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','3'],
['3','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','3'],
['3','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','3'],
['3','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','3'],
['3','0','0','0','0','0','0','0','0','1','0','0','0','0','0','0','0','0','0','3'],
['3','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','3'],
['3','0','0','0','0','0','0','0','0','0','0','0','3','0','0','0','3','0','0','3'],
['3','0','0','0','0','0','0','0','0','0','0','3','0','0','0','0','0','3','0','3'],
['3','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','3'],
['3','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','3'],
['3','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','3'],
['3','0','0','0','0','0','0','0','0','0','3','0','0','0','0','0','0','0','0','3'],
['3','0','0','0','0','0','0','3','0','0','0','0','0','0','4','0','0','3','0','3'],
['3','0','0','0','0','0','0','0','0','0','0g','0','0','0','0','0','3','0','0','3'],
['3','0','0','0','0','0','0','0','0','0','0','0','0','3','0','0','0','0','0','3'],
['3','0','0','0','0','0','0','0','3','0','0','0','0','0','0','0','0','0','0','3'],
['3','3','3','3','3','3','3','3','3','3','3','3','3','3','3','3','3','3','3','3'],
];
var xs=16;var ys=10;
var sd=2;
var xh=7;var yh=9;
</SCRIPT>
Et voici le code source que ce code génère lorsque j'ouvre la page avec internet explorer:
<SCRIPT laguage="javascript">
var tabnv=[ ['','','','','','','','','','','','','','','','','','','',''],
['','','','','','','','','','','','','','','','','','','',''],
['','','','','','','','','','','','','','','','','','','',''],
['','','','','','','','','','','','','','','','','','','',''],
['','','','','','','','','','','','','','','','','','','',''],
['','','','','','','','','','','','','','','','','','','',''],
['','','','','','','','','','','','','','','','','','','',''],
['','','','','','','','','','','','','','','','','','','',''],
['','','','','','','','','','','','','','','','','','','',''],
['','','','','','','','','','','','','','','','','','','',''],
['','','','','','','','','','','','','','','','','','','',''],
['','','','','','','','','','','','','','','','','','','',''],
['','','','','','','','','','','','','','','','','','','',''],
['','','','','','','','','','','','','','','','','','','',''],
['','','','','','','','','','','','','','','','','','','',''],
['','','','','','','','','','','','','','','','','','','',''],
['','','','','','','','','','','','','','','','','','','',''],
['','','','','','','','','','','','','','','','','','','',''],
['','','','','','','','','','','','','','','','','','','',''],
['','','','','','','','','','','','','','','','','','','',''],
];
var xs=;var ys=;
var sd=;
var xh=;var yh=;
</SCRIPT>
Le plus abérant c'est que j'utilise ce même principe sur une autre page ou ça marche impeccablement sur les deux navigateurs.