Problème en PHP
princesseF
Messages postés
37
Date d'inscription
Statut
Membre
Dernière intervention
-
youkc Messages postés 46 Date d'inscription Statut Membre Dernière intervention -
youkc Messages postés 46 Date d'inscription Statut Membre Dernière intervention -
Bonjour à tous,
je fais une application web avec php je suis entrain de modifier un produit mais lorsque je met le code suivant :
<?php
$lib=$_POST["libelle"];
mysql_connect("localhost","root","") or die("Erreur Connexion Serveur");
mysql_select_db("hamdi") or die ("Erreur Connexion Base");
$req = "select * from produit where libellé='$lib' ";
mysql_query($req) or die("erreur table produit");
$ligne= mysql_fetch_row($req);
if (mysql_num_rows($req)==0)
echo "Enregistrement non existant";
else
{
echo "<strong>Affichage de l'enregistrement $lib </strong><br>";}?>
<form id="form1" name="form1" method="post" action="modifier1.php">
<table align="center" border="1" >
<tr> <td class="TitreCellule"> Libellé </td>
<td><input name="libelle" type="text" value= "<?php echo "$ligne[0]"; ?>" size="40" readonly="true">
</td> </tr>";
<tr > <td class="TitreCellule">quantité</td>
<td><input name="qt" type="text" value="<?php echo "$ligne[1]"; ?>" size="40" readonly></td>
</tr>";
<tr > <td class="TitreCellule">Prix</td>
<td><input name="prix" type="text" value="<?php echo"$ligne[2]"; ?>" size="40" readonly></td>
</tr>";
<tr > <td class="TitreCellule">Type</td>
<td><input name="type" type="text" value="<?php echo"$ligne[3]"; ?>" size="40" readonly></td>
</tr>";
<tr><td><input type="reset" value=" Effacer "></td><td><input
type="submit" name="modifier" value="Enregistrer"></td></tr></table>
</form>
=> il s'affiche
1)Warning: mysql_fetch_row() expects parameter 1 to be resource
2)Warning: mysql_num_rows() expects parameter 1 to be resource
quelles sont les problèmes vous pouvez m'aider s'il vous plait
merci d'avance
je fais une application web avec php je suis entrain de modifier un produit mais lorsque je met le code suivant :
<?php
$lib=$_POST["libelle"];
mysql_connect("localhost","root","") or die("Erreur Connexion Serveur");
mysql_select_db("hamdi") or die ("Erreur Connexion Base");
$req = "select * from produit where libellé='$lib' ";
mysql_query($req) or die("erreur table produit");
$ligne= mysql_fetch_row($req);
if (mysql_num_rows($req)==0)
echo "Enregistrement non existant";
else
{
echo "<strong>Affichage de l'enregistrement $lib </strong><br>";}?>
<form id="form1" name="form1" method="post" action="modifier1.php">
<table align="center" border="1" >
<tr> <td class="TitreCellule"> Libellé </td>
<td><input name="libelle" type="text" value= "<?php echo "$ligne[0]"; ?>" size="40" readonly="true">
</td> </tr>";
<tr > <td class="TitreCellule">quantité</td>
<td><input name="qt" type="text" value="<?php echo "$ligne[1]"; ?>" size="40" readonly></td>
</tr>";
<tr > <td class="TitreCellule">Prix</td>
<td><input name="prix" type="text" value="<?php echo"$ligne[2]"; ?>" size="40" readonly></td>
</tr>";
<tr > <td class="TitreCellule">Type</td>
<td><input name="type" type="text" value="<?php echo"$ligne[3]"; ?>" size="40" readonly></td>
</tr>";
<tr><td><input type="reset" value=" Effacer "></td><td><input
type="submit" name="modifier" value="Enregistrer"></td></tr></table>
</form>
=> il s'affiche
1)Warning: mysql_fetch_row() expects parameter 1 to be resource
2)Warning: mysql_num_rows() expects parameter 1 to be resource
quelles sont les problèmes vous pouvez m'aider s'il vous plait
merci d'avance
A voir également:
- Problème en PHP
- 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
1 réponse
au lieu de :
$req = "select * from produit where libellé='$lib' ";
mysql_query($req) or die("erreur table produit");
$ligne= mysql_fetch_row($req);
if (mysql_num_rows($req)==0)
il faut faire:
................................
$req = "select * from produit where libellé='$lib' ";
$sql = mysql_query($req) or die("erreur table produit");
$ligne= mysql_fetch_row($sql);
if (mysql_num_rows($sql)==0)
..................................
............................
$req = "select * from produit where libellé='$lib' ";
mysql_query($req) or die("erreur table produit");
$ligne= mysql_fetch_row($req);
if (mysql_num_rows($req)==0)
il faut faire:
................................
$req = "select * from produit where libellé='$lib' ";
$sql = mysql_query($req) or die("erreur table produit");
$ligne= mysql_fetch_row($sql);
if (mysql_num_rows($sql)==0)
..................................
............................
youkc
Messages postés
46
Date d'inscription
Statut
Membre
Dernière intervention
3
verifie si ca marche ou pas