Problème PHP
Résolu
killersources
Messages postés
23
Date d'inscription
Statut
Membre
Dernière intervention
-
killersources Messages postés 23 Date d'inscription Statut Membre Dernière intervention -
killersources Messages postés 23 Date d'inscription Statut Membre Dernière intervention -
Bonjour à tous,
Voilà je suis super débutant en php et j'ai un soucis avec mon code mais je ne comprends rien (pour être honnête)...
Cela fait maintenant 3 jours que je me casse les dents la dessus et j'espère que vous pourrez m'aider.
Voici le message erreur:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /opt/guide/www.amisprl.be/HTML/mcvs/admin.php on line 40
Voici mon code:
<?php
include("variables.inc.php");
include("identification.inc.php");
include("haut.inc.php");
$liendb = mysql_connect ("localhost", "user", "pass")
mysql_select_db ("db");
?>
<p align="left"> Acceuil dossier client</p>
<form action="admin.php" method="post">
<input type="text" name="motclef" value="<?php echo $_REQUEST['motclef']; ?>" />
<input type="submit" value="rechercher">
</form>
<table width="90%" align="center" border="1">
<tr>
<td class="intitule">Numéro client</td>
<td class="intitule">Société</td>
<td class="intitule"> </td>
</tr>
<?php
$clause = '';
if (isset($_REQUEST['motclef']))
{
$clause .= " WHERE INSTR(nom,'".$_REQUEST ['motclef']."')";
$clause .= " OR INSTR(id,'".$_REQUEST ['motclef']."')";
}
$sql = "SELECT FROM clients ".$clause;
$resultat = mysql_query ($sql);
while ($clients = mysql_fetch_array ($resultat)) ==>> la ligne qui me renvoi l'erreur.
{
$id = $clients['id_client'];
$nom = $clients['Societe'];
echo "<tr>";
echo "<td>$id</td>";
echo "<td>$nom</td>";
echo "<td>";
echo "<a href='clients_edit.php?id=$id'>voir</a>";
echo "</td>";
echo "</tr>";
}
echo "</table>";
?>
<?php
mysql_close($liendb);
include("bas.inc.php");
?>
Merci d'avance à ceux qui prendront un peu de leurs temps pour m'aider.
Voilà je suis super débutant en php et j'ai un soucis avec mon code mais je ne comprends rien (pour être honnête)...
Cela fait maintenant 3 jours que je me casse les dents la dessus et j'espère que vous pourrez m'aider.
Voici le message erreur:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /opt/guide/www.amisprl.be/HTML/mcvs/admin.php on line 40
Voici mon code:
<?php
include("variables.inc.php");
include("identification.inc.php");
include("haut.inc.php");
$liendb = mysql_connect ("localhost", "user", "pass")
mysql_select_db ("db");
?>
<p align="left"> Acceuil dossier client</p>
<form action="admin.php" method="post">
<input type="text" name="motclef" value="<?php echo $_REQUEST['motclef']; ?>" />
<input type="submit" value="rechercher">
</form>
<table width="90%" align="center" border="1">
<tr>
<td class="intitule">Numéro client</td>
<td class="intitule">Société</td>
<td class="intitule"> </td>
</tr>
<?php
$clause = '';
if (isset($_REQUEST['motclef']))
{
$clause .= " WHERE INSTR(nom,'".$_REQUEST ['motclef']."')";
$clause .= " OR INSTR(id,'".$_REQUEST ['motclef']."')";
}
$sql = "SELECT FROM clients ".$clause;
$resultat = mysql_query ($sql);
while ($clients = mysql_fetch_array ($resultat)) ==>> la ligne qui me renvoi l'erreur.
{
$id = $clients['id_client'];
$nom = $clients['Societe'];
echo "<tr>";
echo "<td>$id</td>";
echo "<td>$nom</td>";
echo "<td>";
echo "<a href='clients_edit.php?id=$id'>voir</a>";
echo "</td>";
echo "</tr>";
}
echo "</table>";
?>
<?php
mysql_close($liendb);
include("bas.inc.php");
?>
Merci d'avance à ceux qui prendront un peu de leurs temps pour m'aider.
A voir également:
- Problème 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
6 réponses
J'ai fais la modification et maintenant je n'accède plus au fichier j'ai directement une erreur :
Parse error: syntax error, unexpected T_VARIABLE in /opt/guide/HTML/mcvs/admin.php on line 38
Parse error: syntax error, unexpected T_VARIABLE in /opt/guide/HTML/mcvs/admin.php on line 38
Ca c'est bon j'avais oublié la virgule.
Par contre il me renvoi tjs le premier message comme au départ malgrés la correction que tu m'as indiqué.
mysql_fetch_array(): supplied argument is not a valid MySQL result resource ligne 40
revoici le code:
<?php
include("variables.inc.php");
include("identification.inc.php");
include("haut.inc.php");
$liendb = mysql_connect ("localhost", "", "")
mysql_select_db ("db");
?>
<p align="left"> Acceuil dossier client</p>
<form action="admin.php" method="post">
<input type="text" name="motclef" value="<?php echo $_REQUEST['motclef']; ?>" />
<input type="submit" value="rechercher">
</form>
<table width="90%" align="center" border="1">
<tr>
<td class="intitule">Numéro client</td>
<td class="intitule">Société</td>
<td class="intitule"> </td>
</tr>
<?php
$clause = '';
if (isset($_REQUEST['motclef']))
{
$clause .= " WHERE INSTR(nom,'".$_REQUEST ['motclef']."')";
$clause .= " OR INSTR(id,'".$_REQUEST ['motclef']."')";
}
$sql = "SELECT FROM clients ".$clause;
$resultat = mysql_query ($sql,$liendb);
while ($clients = mysql_fetch_array ($resultat)) ==>> ligne à problème
{
$id = $clients['id_client'];
$nom = $clients['Societe'];
echo "<tr>";
echo "<td>$id</td>";
echo "<td>$nom</td>";
echo "<td>";
echo "<a href='clients_edit.php?id=$id'>voir</a>";
echo "</td>";
echo "</tr>";
}
echo "</table>";
?>
<?php
mysql_close($liendb);
include("bas.inc.php");
?>
Merci de m'aider, c'est super sympa
Par contre il me renvoi tjs le premier message comme au départ malgrés la correction que tu m'as indiqué.
mysql_fetch_array(): supplied argument is not a valid MySQL result resource ligne 40
revoici le code:
<?php
include("variables.inc.php");
include("identification.inc.php");
include("haut.inc.php");
$liendb = mysql_connect ("localhost", "", "")
mysql_select_db ("db");
?>
<p align="left"> Acceuil dossier client</p>
<form action="admin.php" method="post">
<input type="text" name="motclef" value="<?php echo $_REQUEST['motclef']; ?>" />
<input type="submit" value="rechercher">
</form>
<table width="90%" align="center" border="1">
<tr>
<td class="intitule">Numéro client</td>
<td class="intitule">Société</td>
<td class="intitule"> </td>
</tr>
<?php
$clause = '';
if (isset($_REQUEST['motclef']))
{
$clause .= " WHERE INSTR(nom,'".$_REQUEST ['motclef']."')";
$clause .= " OR INSTR(id,'".$_REQUEST ['motclef']."')";
}
$sql = "SELECT FROM clients ".$clause;
$resultat = mysql_query ($sql,$liendb);
while ($clients = mysql_fetch_array ($resultat)) ==>> ligne à problème
{
$id = $clients['id_client'];
$nom = $clients['Societe'];
echo "<tr>";
echo "<td>$id</td>";
echo "<td>$nom</td>";
echo "<td>";
echo "<a href='clients_edit.php?id=$id'>voir</a>";
echo "</td>";
echo "</tr>";
}
echo "</table>";
?>
<?php
mysql_close($liendb);
include("bas.inc.php");
?>
Merci de m'aider, c'est super sympa
si par paramètres nul tu entends dans la structure de ma table colonne NULL tout est sur non sinon c'est que je comprends pas, je m'en excuse car suis vraiment super débutant. Encore merci pour ton aide.
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
J 'ai ajouté un or die(mysql_error()); sur la ligne précedente.
Voici le code qui fonctionne:
<?php
include("variables.inc.php");
include("identification.inc.php");
include("haut.inc.php");
$liendb = mysql_connect ("localhost", "user", "pass")
mysql_select_db ("db");
?>
<p align="left"> Acceuil dossier client</p>
<form action="admin.php" method="post">
<input type="text" name="motclef" value="<?php echo $_REQUEST['motclef']; ?>" />
<input type="submit" value="rechercher">
</form>
<table width="90%" align="center" border="1">
<tr>
<td class="intitule">Numéro client</td>
<td class="intitule">Société</td>
<td class="intitule"> </td>
</tr>
<?php
$clause = '';
if (isset($_REQUEST['motclef']))
{
$clause .= " WHERE INSTR(nom,'".$_REQUEST ['motclef']."')";
$clause .= " OR INSTR(id,'".$_REQUEST ['motclef']."')";
}
$sql = "SELECT FROM clients ".$clause;
$resultat = mysql_query ($sql) or die(mysql_error());
while ($clients = mysql_fetch_array ($resultat))
{
$id = $clients['id_client'];
$nom = $clients['Societe'];
echo "<tr>";
echo "<td>$id</td>";
echo "<td>$nom</td>";
echo "<td>";
echo "<a href='clients_edit.php?id=$id'>voir</a>";
echo "</td>";
echo "</tr>";
}
echo "</table>";
?>
<?php
mysql_close($liendb);
include("bas.inc.php");
?>
Voilà, encore merci pour ton aide
Voici le code qui fonctionne:
<?php
include("variables.inc.php");
include("identification.inc.php");
include("haut.inc.php");
$liendb = mysql_connect ("localhost", "user", "pass")
mysql_select_db ("db");
?>
<p align="left"> Acceuil dossier client</p>
<form action="admin.php" method="post">
<input type="text" name="motclef" value="<?php echo $_REQUEST['motclef']; ?>" />
<input type="submit" value="rechercher">
</form>
<table width="90%" align="center" border="1">
<tr>
<td class="intitule">Numéro client</td>
<td class="intitule">Société</td>
<td class="intitule"> </td>
</tr>
<?php
$clause = '';
if (isset($_REQUEST['motclef']))
{
$clause .= " WHERE INSTR(nom,'".$_REQUEST ['motclef']."')";
$clause .= " OR INSTR(id,'".$_REQUEST ['motclef']."')";
}
$sql = "SELECT FROM clients ".$clause;
$resultat = mysql_query ($sql) or die(mysql_error());
while ($clients = mysql_fetch_array ($resultat))
{
$id = $clients['id_client'];
$nom = $clients['Societe'];
echo "<tr>";
echo "<td>$id</td>";
echo "<td>$nom</td>";
echo "<td>";
echo "<a href='clients_edit.php?id=$id'>voir</a>";
echo "</td>";
echo "</tr>";
}
echo "</table>";
?>
<?php
mysql_close($liendb);
include("bas.inc.php");
?>
Voilà, encore merci pour ton aide