PHP : variable qui ne se transmet pas
Résolu
Ninja_En_Short
Messages postés
133
Date d'inscription
Statut
Membre
Dernière intervention
-
Tiller Messages postés 781 Date d'inscription Statut Membre Dernière intervention -
Tiller Messages postés 781 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
Alors petit probleme : j'ai un variable qui est envoyé à la page employant une fonction qui fait un include (qui fonctionne parfaitement) d'une autre dont voici le code :
<?php
$connect2 = mysql_connect("localhost", "NES", "grobeta");
mysql_select_db("CMS_NES-Tech");
echo $_GET['theme_del'];
if (isset($_POST['addtheme'])){
add_theme($_POST['theme_name_field'], $_POST['theme_path_field']);
}
if (isset($_GET['theme_act'])){
$query_act = "SELECT theme_num FROM affichage WHERE statut = 1";
$res_act = mysql_query($query_act);
if (mysql_num_rows($res_act) != 0){
$query_deact_update = "UPDATE affichage SET statut = 0 WHERE affichage.statut = 1";
mysql_query($query_deact_update);
$query_act_update = "UPDATE affichage SET statut = 1 WHERE theme_num=".$_GET['theme_act'];
mysql_query($query_act_update);
}else{
$query_act_update = "UPDATE affichage SET statut = 1 WHERE theme_num=".$_GET['theme_act'];
mysql_query($query_act_update);
}
}
if (isset($_GET['theme_del'])){
delete_theme($_GET['theme_del']);
}
$query_actuMod_num = "SELECT module_num FROM modules WHERE module_name = '".$_GET['page']."'";
$resModNum = mysql_query($query_actuMod_num);
$modNum = mysql_fetch_array($resModNum);
mysql_close($connect2);
?>
<div align = 'left'>
<div align = 'center'>
<form action = "admin.php" method = "post" align = 'center'>
<table align = 'center'>
<tr>
<td>Nom du theme</td>
<td> <input type="textfield" accesskey="20" name="theme_name_field" /> </td>
</tr>
<tr>
<td>Chemin vers le dossier du theme </td>
<td> <input type="textfield" accesskey="20" name="theme_path_field" /> </td>
</tr>
<tr align = 'center'>
<td><input type="submit" name="addtheme" value="Ajouter"></td>
</tr>
</table>
</form>
</div>
</div>
<?php
$connex = mysql_connect("localhost","NES","grobeta");
mysql_select_db("CMS_NES-Tech");
$query_affichage = "SELECT theme_num, theme_name, theme_path FROM affichage";
$res_affichage = mysql_query($query_affichage);
mysql_close($connex);
if (mysql_num_rows($res_affichage) != 0){
?>
<div>
<table border = 1 align = 'center' width = 80%>
<tr>
<th>Numéro de theme</th>
<th>Nom de theme</th>
<th>Chemin vers le dossier du theme</th>
<th>Statut</th>
<th>Activation / Suppression</th>
</tr>
<?php
while ($array_res = mysql_fetch_array($res_affichage)) { ?>
<tr>
<td>
<?php echo $array_res['0']; ?>
</td>
<td>
<?php echo $array_res['1']; ?>
</td>
<td>
<?php echo $array_res['2']; ?>
</td>
<td>
<?php is_active($array_res['0']) ?>
</td>
<td>
<table align = 'center'>
<tr>
<td width = 50% align='center'>
<?php
echo $array_res['0']."<br />";
echo "<a href='admin.php?theme_act='". $array_res['0'] ."<img src='images/ok.png' title='ok' height='30' width='30'></a>"; ?>
</td>
<td width = 50% align='center'>
<?php echo "<a href='admin.php?theme_del='". $array_res['0'] ."<img src='images/trashempty.png' title='trashempty' height='30' width='30'></a>"; ?>
</td>
</tr>
</table>
</td>
</tr>
<?php
}
?>
</div>
<?php
}else{
echo "Aucun theme enregistré";
}
function theme_php_path ($path){
$proper_theme_path = "";
$theme_path = explode("\\",$path);
$i = 0;
while($array_path = $theme_path){
$proper_theme_path.$array_path[$i]."/";
$i++;
}
return $proper_theme_path;
}
function add_theme ($name, $path){
$connex2 = mysql_connect("localhost","NES","grobeta");
mysql_select_db("CMS_NES-Tech");
$query_insert = "INSERT INTO affichage ('theme_num', 'theme_name', 'theme_path', 'statut')VALUES (NULL , '".$name."', '".theme_php_path($path)."', 0)";
$res_insert = mysql_query($query_insert);
mysql_close($connex2);
}
function is_active ($id){
$connex3 = mysql_connect("localhost","NES","grobeta");
mysql_select_db("CMS_NES-Tech");
$query_is_active = "SELECT statut FROM affichage WHERE theme_num = ".$id;
$res_is_active = mysql_query($query_is_active);
$array_is_active = mysql_fetch_array($res_is_active);
mysql_close($connex3);
if ($array_is_active['0'] == 1){
echo "Active";
}else{
echo "Desactive";
}
}
function delete_theme ($id){
echo $id;
$connex4 = mysql_connect("localhost","NES","grobeta");
mysql_select_db("CMS_NES-Tech");
$query_delete = "DELETE FROM affichage WHERE theme_num = ".$id;
echo $query_delete;
$res_delete = mysql_query($query_delete);
$array_delete = mysql_fetch_array($res_delete);
mysql_close($connex4);
}
?>
Cette page de mon CMS me sert à administrer l'affichage sur mon site, le problème étant que les variables de la sections en gras ne passent pas, theme_del et theme_act restent vide. Les parties en traitant sont en gras dans le code.
Les fonctions sont correctes, je les ai déjà vérifiées c'est uniquement un problème de transmission des variables.
Merci
Alors petit probleme : j'ai un variable qui est envoyé à la page employant une fonction qui fait un include (qui fonctionne parfaitement) d'une autre dont voici le code :
<?php
$connect2 = mysql_connect("localhost", "NES", "grobeta");
mysql_select_db("CMS_NES-Tech");
echo $_GET['theme_del'];
if (isset($_POST['addtheme'])){
add_theme($_POST['theme_name_field'], $_POST['theme_path_field']);
}
if (isset($_GET['theme_act'])){
$query_act = "SELECT theme_num FROM affichage WHERE statut = 1";
$res_act = mysql_query($query_act);
if (mysql_num_rows($res_act) != 0){
$query_deact_update = "UPDATE affichage SET statut = 0 WHERE affichage.statut = 1";
mysql_query($query_deact_update);
$query_act_update = "UPDATE affichage SET statut = 1 WHERE theme_num=".$_GET['theme_act'];
mysql_query($query_act_update);
}else{
$query_act_update = "UPDATE affichage SET statut = 1 WHERE theme_num=".$_GET['theme_act'];
mysql_query($query_act_update);
}
}
if (isset($_GET['theme_del'])){
delete_theme($_GET['theme_del']);
}
$query_actuMod_num = "SELECT module_num FROM modules WHERE module_name = '".$_GET['page']."'";
$resModNum = mysql_query($query_actuMod_num);
$modNum = mysql_fetch_array($resModNum);
mysql_close($connect2);
?>
<div align = 'left'>
<div align = 'center'>
<form action = "admin.php" method = "post" align = 'center'>
<table align = 'center'>
<tr>
<td>Nom du theme</td>
<td> <input type="textfield" accesskey="20" name="theme_name_field" /> </td>
</tr>
<tr>
<td>Chemin vers le dossier du theme </td>
<td> <input type="textfield" accesskey="20" name="theme_path_field" /> </td>
</tr>
<tr align = 'center'>
<td><input type="submit" name="addtheme" value="Ajouter"></td>
</tr>
</table>
</form>
</div>
</div>
<?php
$connex = mysql_connect("localhost","NES","grobeta");
mysql_select_db("CMS_NES-Tech");
$query_affichage = "SELECT theme_num, theme_name, theme_path FROM affichage";
$res_affichage = mysql_query($query_affichage);
mysql_close($connex);
if (mysql_num_rows($res_affichage) != 0){
?>
<div>
<table border = 1 align = 'center' width = 80%>
<tr>
<th>Numéro de theme</th>
<th>Nom de theme</th>
<th>Chemin vers le dossier du theme</th>
<th>Statut</th>
<th>Activation / Suppression</th>
</tr>
<?php
while ($array_res = mysql_fetch_array($res_affichage)) { ?>
<tr>
<td>
<?php echo $array_res['0']; ?>
</td>
<td>
<?php echo $array_res['1']; ?>
</td>
<td>
<?php echo $array_res['2']; ?>
</td>
<td>
<?php is_active($array_res['0']) ?>
</td>
<td>
<table align = 'center'>
<tr>
<td width = 50% align='center'>
<?php
echo $array_res['0']."<br />";
echo "<a href='admin.php?theme_act='". $array_res['0'] ."<img src='images/ok.png' title='ok' height='30' width='30'></a>"; ?>
</td>
<td width = 50% align='center'>
<?php echo "<a href='admin.php?theme_del='". $array_res['0'] ."<img src='images/trashempty.png' title='trashempty' height='30' width='30'></a>"; ?>
</td>
</tr>
</table>
</td>
</tr>
<?php
}
?>
</div>
<?php
}else{
echo "Aucun theme enregistré";
}
function theme_php_path ($path){
$proper_theme_path = "";
$theme_path = explode("\\",$path);
$i = 0;
while($array_path = $theme_path){
$proper_theme_path.$array_path[$i]."/";
$i++;
}
return $proper_theme_path;
}
function add_theme ($name, $path){
$connex2 = mysql_connect("localhost","NES","grobeta");
mysql_select_db("CMS_NES-Tech");
$query_insert = "INSERT INTO affichage ('theme_num', 'theme_name', 'theme_path', 'statut')VALUES (NULL , '".$name."', '".theme_php_path($path)."', 0)";
$res_insert = mysql_query($query_insert);
mysql_close($connex2);
}
function is_active ($id){
$connex3 = mysql_connect("localhost","NES","grobeta");
mysql_select_db("CMS_NES-Tech");
$query_is_active = "SELECT statut FROM affichage WHERE theme_num = ".$id;
$res_is_active = mysql_query($query_is_active);
$array_is_active = mysql_fetch_array($res_is_active);
mysql_close($connex3);
if ($array_is_active['0'] == 1){
echo "Active";
}else{
echo "Desactive";
}
}
function delete_theme ($id){
echo $id;
$connex4 = mysql_connect("localhost","NES","grobeta");
mysql_select_db("CMS_NES-Tech");
$query_delete = "DELETE FROM affichage WHERE theme_num = ".$id;
echo $query_delete;
$res_delete = mysql_query($query_delete);
$array_delete = mysql_fetch_array($res_delete);
mysql_close($connex4);
}
?>
Cette page de mon CMS me sert à administrer l'affichage sur mon site, le problème étant que les variables de la sections en gras ne passent pas, theme_del et theme_act restent vide. Les parties en traitant sont en gras dans le code.
Les fonctions sont correctes, je les ai déjà vérifiées c'est uniquement un problème de transmission des variables.
Merci
A voir également:
- PHP : variable qui ne se transmet pas
- Easy php - Télécharger - Divers Web & Internet
- Expert php pinterest - Télécharger - Langages
- Retour a la ligne php - Forum Webmastering
- Alert php - Forum PHP
- Retour a la ligne php ✓ - Forum PHP
3 réponses
Utilise la balise < code > la prochaine fois
Huuum, y'a quoi dans $array_res['0'] ? Car la je pense pas que se soit sa du tout..
D'après moi ton truc donne quelque chose du style:
Et en html c'est rien... Sa c'est bien:
donc je suppose que c'est plutot:
echo "<a href='admin.php?theme_act='". $array_res['0'] ."<img src='images/ok.png' title='ok' height='30' width='30'></a>"; ?>
Huuum, y'a quoi dans $array_res['0'] ? Car la je pense pas que se soit sa du tout..
D'après moi ton truc donne quelque chose du style:
<a href='admin.php?theme_act='theme1<img src='images/ok.png' title='ok' height='30' width='30'></a>
Et en html c'est rien... Sa c'est bien:
<a href='admin.php?theme_act=theme1'><img src='images/ok.png' title='ok' height='30' width='30'></a>
donc je suppose que c'est plutot:
<td width = 50% align='center'> <?php echo $array_res['0']."<br />"; echo "<a href='admin.php?theme_act=". $array_res['0'] ."'><img src='images/ok.png' title='ok' height='30' width='30'></a>"; ?> </td> <td width = 50% align='center'> <?php echo "<a href='admin.php?theme_del=". $array_res['0'] ."'><img src='images/trashempty.png' title='trashempty' height='30' width='30'></a>"; ?> </td>