Click here to Skip to main content
15,889,096 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I would like update the URL of my file into a Database.
I have already added the URL with INSERT INTO function.
Now, I would like to Update it. But, I receive an error concerning the number of parameters. But, all paremeters are correctly named.
I need your help.

Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined

What I have tried:

PHP
$DestFichier = "ImgArticles/Illustrations/".$NomFichier;
$URL = "ImgArticles/Illustrations/".$NomFichier;
if (move_uploaded_file($TempoFichier, $DestFichier)) {
	$reqModImages = $bdd->prepare('UPDATE images 
								SET 
									nm_img = :Nom_image, 
									info_img = :Infos_image, 
									prix_art = :Prix, 
									src_img = :URL_image, 
									type_img = :Type_image 
								WHERE id_img = :ID');
		$reqModImages->execute(array(
						'Nom_image' => strip_tags($_POST['NewName']),
						'Infos_image' => Strip_tags($_POST['NewDetailsImages']),
						'Prix' => strip_tags($_POST['NewCost']),
						'Url_image' => $URL,
						'Type_image' => $TypeFichier,
						'ID' => strip_tags($_POST['id']),
						));

						echo ' alert ("FICHIER BIEN MODIFIE")</>';
						header('Refresh: 1;URL=GestionImages.php#Aff');
					}
Posted
Updated 18-May-22 20:42pm
v2

Read carefilly your code
PHP
$reqModImages = $bdd->prepare('UPDATE images
                            SET
                                nm_img = :Nom_image,
                                info_img = :Infos_image,
                                prix_art = :Prix,
                                src_img = :URL_image,
                                type_img = :Type_image
                            WHERE id_img = :ID');
    $reqModImages->execute(array(
                    'Nom_image' => strip_tags($_POST['NewName']),
                    'Infos_image' => Strip_tags($_POST['NewDetailsImages']),
                    'Prix' => strip_tags($_POST['NewCost']),
                    'Url_image' => $URL,
                    'Type_image' => $TypeFichier,
                    'ID' => strip_tags($_POST['id']),
                    ));

Parameter names are case sensitives.
 
Share this answer
 
Comments
GS Wilfried LOBA 9-Jun-22 14:33pm    
Thank you very much for your comment. I knew the error was on the src_img line, but I didn't know what it was.
Cool !
Patrice T 9-Jun-22 14:54pm    
Nice to know, you should accept my solution, it tells the question is answered.
Hello Mr LOBA,

the syntax is bad for pdo->prepare() .

look at it from php ( and mysql pdo ) :

PHP: PDO::prepare - Manual[^]
 
Share this answer
 
Comments
GS Wilfried LOBA 9-Jun-22 14:34pm    
Thanks a lot for your help. Your link will be useful to me.

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