[PHP] Could not insert data into users table

Résolu/Fermé
Linkinou - 18 août 2009 à 11:04
 Linkinou - 18 août 2009 à 13:12
Bonjour !

Voilà voilà, j'allais mettre mon forum phpbb modifié en ligne jusqu'a ce que je trouve une erreur lors de l'inscription :

Could not insert data into users table

DEBUG MODE

INSERT INTO phpbb_users (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_birthday, user_zodiac, user_sig, user_sig_bbcode_uid, user_avatar, user_avatar_type, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmile, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_allow_mass_pm, user_popup_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey) VALUES (3, 'lol', 1250559618, '9cdfb439c7876e703e307864c9167a15', 'lol@hotmail.fr', '', '', '', '', '', '', 0, '', '', '', 0, 0, '', '', '', 1, 1, 0, 1, 1, 0, 1, , 1, 0, 'D M d, Y g:i a', 'french', 2, 0, 1, 0, '9d28ebbe35cea1a')

Line : 742
File : usercp_register.php


Et voilà tout ce que j'ai vers la ligne 742 :

//
			// Get current date
			//
			//-- mod : birthday ------------------------------------------------------------
// here we added
//	, user_birthday, user_zodiac
//	, '" . $birthday->pack(array('d' => $bday_day, 'm' => $bday_month, 'y' => $bday_year)) . "', $user_zodiac
//-- modify
			$sql = "INSERT INTO " . USERS_TABLE . "	(user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_birthday, user_zodiac, user_sig, user_sig_bbcode_uid, user_avatar, user_avatar_type, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmile, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_allow_mass_pm, user_popup_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey)
				VALUES ($user_id, '" . str_replace("\'", "''", $username) . "', " . time() . ", '" . str_replace("\'", "''", $new_password) . "', '" . str_replace("\'", "''", $email) . "', '" . str_replace("\'", "''", $icq) . "', '" . str_replace("\'", "''", $website) . "', '" . str_replace("\'", "''", $occupation) . "', '" . str_replace("\'", "''", $location) . "', '" . str_replace("\'", "''", $interests) . "', '" . $birthday->pack(array('d' => $bday_day, 'm' => $bday_month, 'y' => $bday_year)) . "', $user_zodiac, '" . str_replace("\'", "''", $signature) . "', '$signature_bbcode_uid', $avatar_sql, $viewemail, '" . str_replace("\'", "''", str_replace(' ', '+', $aim)) . "', '" . str_replace("\'", "''", $yim) . "', '" . str_replace("\'", "''", $msn) . "', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $allow_mass_pm, $popup_pm, $user_timezone, '" . str_replace("\'", "''", $user_dateformat) . "', '" . str_replace("\'", "''", $user_lang) . "', $user_style, 0, 1, ";
				//-- fin mod : birthday --------------------------------------------------------
			if ( $board_config['require_activation'] == USER_ACTIVATION_SELF || $board_config['require_activation'] == USER_ACTIVATION_ADMIN || $coppa )
			{
				$user_actkey = gen_rand_string(true);
				$key_len = 54 - (strlen($server_url));
				$key_len = ( $key_len > 6 ) ? $key_len : 6;
				$user_actkey = substr($user_actkey, 0, $key_len);
				$sql .= "0, '" . str_replace("\'", "''", $user_actkey) . "')";
			}
			else
			{
				$sql .= "1, '')";
			}

			if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) )
			{
				message_die(GENERAL_ERROR, 'Could not insert data into users table', '', __LINE__, __FILE__, $sql);
			}

			$sql = "INSERT INTO " . GROUPS_TABLE . " (group_name, group_description, group_single_user, group_moderator)
				VALUES ('', 'Personal User', 1, 0)";
			if ( !($result = $db->sql_query($sql)) )
			{
				message_die(GENERAL_ERROR, 'Could not insert data into groups table', '', __LINE__, __FILE__, $sql);
			}

			$group_id = $db->sql_nextid();



Je ne parviens pas à trouver d'où peut venir le problème \=
A voir également:

3 réponses

scriptiz Messages postés 1424 Date d'inscription dimanche 21 décembre 2008 Statut Membre Dernière intervention 14 septembre 2023 425
18 août 2009 à 12:07
Dans ta requête d'insertion (cfr lerreur), le nombre de champs affectés et le nombre de VALUES ne correspondent pas.

De plus, à un moment il n'y a rien entre deux virgules séparant deux valeurs :
[code]1, , 1[/code]
0
Merci de ta reponse,

Cependant un ami à comparer les champs/valeurs et il n'a pas trouver d'incoherence :

user_id 3,
username 'lol',    
user_name
user_regdate 1250559618,
user_password '9cdfb439c7876e703e307864c9167a15',
user_email'lol@hotmail.fr',
user_icq '',
user_website '',
user_occ '',
user_from '',
user_interests '',
user_birthday '',
user_zodiac 0,
user_sig '',
user_sig_bbcode_uid '',
user_avatar '',
user_avatar_type 0,
user_viewemail 0,
user_aim '',
user_yim '',
user_msnm '',
user_attachsig 1,
user_allowsmile 1,
user_allowhtml 0,
user_allowbbcode 1,
user_allow_viewonline 1,
user_notify 0,
user_notify_pm 1,
user_allow_mass_pm ,            <-- la fameuse valeur invisible qui est surement un false
user_popup_pm 1,
user_timezone 0,
user_dateformat 'D M d, Y g:i a',
user_lang 'french',
user_style 2,
user_level 0,
user_allow_pm 1,
user_active 0,
user_actkey '9d28ebbe35cea1a'
0
Problème réglé =)

Le soucis venait de ceci :
$allow_mass_pm = ( isset($HTTP_POST_VARS['allow_mass_pm']) ) ? intval ($HTTP_POST_VARS['allow_mass_pm']) : 2;

Qui était mal placé dans ma page d'inscription.

Merci de ton attention scriptiz ;)
0