With bindParam, you can only pass variables not values
with bindValue, you can pass both (values, obviously, and variables)
bindParam works only with variables because it allows parameters to be given as input/output, by “reference” (and a value is not a valid “reference” in PHP): it is used with drivers that (quoting the manual) :
With some DB engines, stored procedures can have parameters that can be used for both input (giving a value from PHP to the procedure) and output (returning a value from the stored proc to PHP); to bind those parameters, you’ve got to use bindParam, and not bindValue.
In case you got any question regarding this section, kindly ask questions in the commenting system below
My name is Benson Karue, I was Software Engineer Telenet Co LTD before I quit and joined YouTube and Udemy as an instructor. I have real-world software experience and have a Bachelor’s degree in Mathematics and Computer Science with 6+ years of coding experience and winning several competitions and coding challenges.