 |
|
|
|
 |
Member
|
|
Posts: 41
Join Date: Nov 2011
|
|
|

01-05-2012, 07:30 PM
Hi d3 iti Thank you to take your time for me your are very helpful.
I copy your code and I have this error
Erreur SQL ! INSERT INTO inscription VALUES ("Marie-Claude ", "Courchesne", "176, rue Saint-aimé", "Drummondville", "Québec", "J2B 7T5", "ceejee", "marie_ceejee@hotmail.com", "cerise12345")
Column count doesn't match value count at row 1
|
 |
Super Moderator
|
|
Posts: 4,609
Join Date: Jul 2009
Location: Spain
|
|
|

01-05-2012, 07:35 PM
Hi, chat_sauvage_1,
It seems the problem is in the amount of data to try to insert into the table.
It would be nice to know how many and what type are the fields defined in the MySQL table.
Si este mensaje te ha servido de ayuda no dudes en pulsar sobre el botón karma
|
 |
Member
|
|
Posts: 41
Join Date: Nov 2011
|
|
|

01-06-2012, 12:18 AM
Hi my mysql table is
inscription
CREATE TABLE `inscription` (
`nom` varchar(25) CHARACTER SET utf8 NOT NULL,
`prenom` varchar(25) CHARACTER SET utf8 NOT NULL,
`pseudo` varchar(25) CHARACTER SET utf8 NOT NULL,
`adresse_courriel` varchar(100) CHARACTER SET utf8 NOT NULL,
`adresse` varchar(75) CHARACTER SET utf8 NOT NULL,
`ville` varchar(75) CHARACTER SET utf8 NOT NULL,
`province` varchar(25) CHARACTER SET utf8 NOT NULL,
`code_postale` varchar(6) CHARACTER SET utf8 NOT NULL,
`mot_de_passe` varchar(25) CHARACTER SET utf8 NOT NULL,
`date_du_jour` date NOT NULL,
`nom_du_fichier` varchar(25) CHARACTER SET utf8 NOT NULL,
`grosseur_du_fichier` int(10) NOT NULL,
`titre_du_fichier` varchar(50) CHARACTER SET utf8 NOT NULL,
`description` varchar(255) CHARACTER SET utf8 NOT NULL,
`nom_du_dossier` varchar(50) CHARACTER SET utf8 NOT NULL,
`mid` int(5) NOT NULL,
`ID` int(11) NOT NULL,
KEY `ID` (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci
|
 |
Super Moderator
|
|
Posts: 4,609
Join Date: Jul 2009
Location: Spain
|
|
|

01-06-2012, 07:58 AM
Hi, chat_sauvage_1:
The problem appeared because we used the shorthand MySQL inserting data in the table assuming that there were only fields that we would add.
The problem is solved in the following code. Adjustment would be missing link in the message "insert user venons nous. Return to home page". Also remember that you must change the password to access the database in the following code:
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>INSCRIPTION</title> <script type="text/javascript"> <!-- function MM_validateForm() { //v4.0 if (document.getElementById){ var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments; for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]); if (val) { nm=val.name; if ((val=val.value)!="") { if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); if (p<1 || p==(val.length-1)) errors+='- '+nm+' need to contain a email.\n'; } else if (test!='R') { num = parseFloat(val); if (isNaN(val)) errors+='- '+nm+' need to contain a number.\n'; if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); min=test.substring(8,p); max=test.substring(p+1); if (num<min || max<num) errors+='- '+nm+' neet to contain number between '+min+' and '+max+'.\n'; } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' need to contain a value.\n'; } } if (errors) alert('following bugs have been produced:\n'+errors); document.MM_returnValue = (errors == ''); } } //--> </script> </head> <body> <?php
if (!isset($_POST['prenom'])) { ?> <h1><strong>Inscription</strong></h1> <!-- Add next line (beginer form) --> <form method="post" name="form1" id="form1" action="<?php $_SERVER['PHP_SELF'];?>" onsubmit="MM_validateForm('prenom','','R','nom','','R', 'adresse','','R','ville','','R','province','','R','code_postale','','R','pseudo','','R','adresse_courriel','','R', 'mot_de_passe','','R'); return document.MM_returnValue"> <label for="prenom">Prénom:</label><input type="text" name="prenom" id="prenom" /></br> <label for="nom">Nom:</label> <input type="text" name="nom" id="nom" /></br> <label for="adresse">Adresse:</label> <input type="text" name="adresse" id="adresse" /></br> <label for="ville">Ville:</label><input type="text" name="ville" id="ville" /></br> <label for="province">Province:</label><input type="text" name="province" id="province" /></br> <label for="code_postale">Code postale:</label><input type="text" name="code_postale" id="code_postale" /> </br> <label for="pseudo">Pseudo:</label><input type="text" name="pseudo" id="pseudo" /></br> <label for="adresse_courriel">Adresse courriel:</label><input type="text" name="adresse_courriel" id="adresse_courriel" /> </br> <label for="mot_de_passe">Mot de passe:</label><input type="password" name="mot_de_passe" id="mot_de_passe" /> </br> <input type="submit" name="submit" id="submit" value="Valider" /></br> </form>
<?php } else { //on se connecte à notre base $base = mysql_connect ('mysql16.000webhost.com', 'a5094737_louise1', 'Password'); mysql_select_db ('a5094737_echange', $base);
// sanitize array $_POST for prevent sql injection attacks foreach( $_POST as $variable => $valor ){ $_POST[$variable] = mysql_escape_string($_POST[$variable]); }
//on insere le tuple et au cas ou on écrira un petit messsage erreur si la requete ne passe pas bien $sql = 'INSERT INTO inscription (nom, prenom, pseudo, adresse_courriel, adresse, ville, province, code_postale, mot_de_passe )VALUES ("'.$_POST['nom'].'", "'.$_POST['prenom'].'", "'.$_POST['pseudo'].'","'.$_POST['adresse_courriel'].'", "'.$_POST['adresse'].'", "'.$_POST['ville'].'", "'.$_POST['province'].'", "'.$_POST['code_postale'].'", "'.$_POST['mot_de_passe'].'")';
//on insere le tuple et au cas ou on ecrire un petit message erreur si la requete ne passe pas mysql_query ($sql) or die ('Erreur SQL ! '.$sql.'<br/>'.mysql_error());
//on ferme la connexion a la base mysql_close();
echo 'nous venons inserer <strong>'.$_POST['prenom'].'.</strong> <a href="yourpagehome.html">Return to home page</a>'; }
?> </body> </html>
Si este mensaje te ha servido de ayuda no dudes en pulsar sobre el botón karma
|
 |
Member
|
|
Posts: 41
Join Date: Nov 2011
|
|
|

01-07-2012, 01:36 PM
Ho Wowwwwwwww thank you very very much this work
I work on that 2 month I tried many script I am very happy
Thanks again
chat_sauvage_1
|
 |
Super Moderator
|
|
Posts: 4,609
Join Date: Jul 2009
Location: Spain
|
|
|

01-08-2012, 07:48 AM
I'm glad to know form is working fine
Si este mensaje te ha servido de ayuda no dudes en pulsar sobre el botón karma
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Powered by vBulletin® Version 3.8.2 Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com
|