Click here to Skip to main content
15,887,320 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i made this code to insert csv content in db but i have error message Warning: Array to string conversion in /home/u320889525/domains/best-products.fr/public_html/importcsv.php on line 41 Fatal error: Uncaught PDOException: SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 1 in /home/u320889525/domains/best-products.fr/public_html/importcsv.php:41 Stack trace: #0 /home/u320889525/domains/best-products.fr/public_html/importcsv.php(41): PDOStatement->execute() #1 {main} thrown in /home/u320889525/domains/best-products.fr/public_html/importcsv.php on line 41 its generally due to connection error but i verified it and i have no error messsage
introduction
lorsque je désactive le code d'insertion de la base de données est correct, j'ai un retour de tableau





Utilisation du code
voici le code :

$the_big_array[1],

'description' => $the_big_array[2],

'prix' => $the_big_array[3]

] ;

$sql = "INSÉRER DANS LES VALEURS du fichier (NULL,:name,:description,:prix)" ;

$stmt= $conn->prepare($sql);

$stmt->execute($data);



// Affiche le code dans un format lisible

echo "<pré>" ;

var_dump($the_big_array);

echo "";

*/

?>

db_connect.php

setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
echo 'Échec lors de la connexion : ' . $e->getMessage();
}

?>

What I have tried:

j'ai essayé par le code d'insertion habituel mais j'ai une erreur nommed

Avertissement : Conversion de tableau en chaîne dans /home/u320889525/domains/best-products.fr/public_html/importcsv.php à la ligne 41
Erreur fatale : Uncaught PDOException : SQLSTATE[21S01] : La liste des valeurs d'insertion ne correspond pas à la liste des colonnes : 1136 Colonne le nombre ne correspond pas au nombre de valeurs à la ligne 1 dans /home/u320889525/domains/best-products.fr/public_html/importcsv.php:41 Trace de pile : #0 /home/u320889525/domains/best-products.fr/public_html /importcsv.php(41): PDOStatement->execute() #1 {main} jeté dans /home/u320889525/domains/best-products.fr/public_html/importcsv.php à la ligne 41

j'ai donc essayé la méthode LOAD DATA LOCAL INFILE

mais j'ai un message d'erreur

Erreur fatale : Uncaught TypeError : mysqli_query() : L'argument #1 ($mysql) doit être de type mysqli, PDO donné dans /home/u320889525/domains/best-products.fr/public_html/importcsv.php:24 Stack trace : # 0 /home/u320889525/domains/best-products.fr/public_html/importcsv.php(24): mysqli_query() #1 {main} jeté dans /home/u320889525/domains/best-products.fr/public_html/importcsv. php à la ligne 24


verify db_connect ( correct)
Posted
Updated 24-Sep-21 18:36pm
Comments
Richard MacCutchan 23-Sep-21 4:54am    
1136 Column count doesn't match value count at row 1 in /home/u320889525/domains/best-products.fr/public_html/importcsv.php:41

Where is the 'name' value?

1 solution

name should be extract from csv as once of data
if u talk about username its in db-connect.php but i verified this module and connection is correct
 
Share this answer
 
Comments
Richard Deeming 27-Sep-21 10:03am    
If you want to reply to a comment, click the "Reply" button next to the comment and post a reply.

Do not post your reply as a "solution" to your question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900