Note that there are some explanatory texts on larger screens.

plurals
  1. POHTML POST and fetch array
    primarykey
    data
    text
    <p>I have two problems here:<br> <strong>1.</strong> I have a problem with the value of the checkbox<br> <strong>2.</strong> I have a problem with the mysql_fetch_array($variable, ASSOC); method --> all the data from my database are VARCHAR type</p> <p><strong>1.</strong> All the variable with, at the end 'Cb', signified that this value is from a checkbox of a FORM. If a checkbox is checked, it means that the row (ex: Username) will be in the Select method for my Database (ex: SELECT Username FROM...)</p> <p>I receive this Error 1. Undefined index: fonctionCb in C:\wamp\www\Projet Compte Utilisateur\manip_liste.php on line 7 2. Undefined variable: tab in C:\wamp\www\Projet Compte Utilisateur\manip_liste.php on line 14 ...etc from all the checkbox <strong>if they are not checked</strong> .. here is my PHP code</p> <pre><code>&lt;?php $prep = ""; if(!$_POST['username']) echo 'Nom d\'utilisateur manquant'; if(($_POST["userCb"]) &amp;&amp; ($_POST["suffixeCb"]) &amp;&amp; ($_POST["fonctionCb"]) &amp;&amp; ($_POST["passwordCb"])){ $prep = " * "; $tab = "User SUFFIXE SITE FONCTION PASSWD"; } else{ if($_POST["userCb"]){ $prep += "username ,"; $tab += "USER "; } if($_POST["suffixeCb"]){ $prep += "suffixe ,"; $tab += "SUFFIXE "; } if($_POST["passwordCb"]){ $prep += "password ,"; $tab += "PASSWD "; } if($_POST["siteCb"]){ $prep += "siteWeb ,"; $tab += "SITE "; } if($_POST["fonctionCb"]){ $prep += "fonction "; $tab += "Fx "; } }//ELSE require("db_action.php"); //Require in the database connection. $bd = db_open(); $data = db_select($prep, $_POST["username"]); //Envoie des variables à afficher et du Username pour le SELECT echo "'$tab'"; echo "'$data'"; ?&gt; </code></pre> <p><strong>2.</strong> The second ERROR and also I got this error from the fetch_array method Error: Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in C:\wamp\www\Projet Compte Utilisateur\db_action.php on line 68</p> <p>Here is the code from my method</p> <pre><code>function db_select($prep, $username){ $querycon = "SELECT '$prep' FROM info_compte WHERE username = '$username'"; if(!mysql_query($querycon)){ echo "Il n\'y a aucun '$username' dans la base de données"; $response = ""; } else{ while ($row = mysql_fetch_array(mysql_query($querycon), MYSQL_ASSOC)) printf("%s %s %s %s %s", $row["username"], $row["suffixe"], $row["password"], $row["siteWeb"], $row["fonction"]); //The PRINTF dont work } return $response; }//db_select </code></pre> <p>Thank you all to answer and i specify that i'm a beginner in practice who wants to learn ..</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload