1
I’m making the connection with prepared statments
to insert many variables, and in some cases it takes me a long time to find the mistakes, and now I put in one here and hit me a question:
White spaces make a difference, I can break lines and give spaces quietly?
For example, I can do:
mysqli_stmt_bind_param($stmt,
'sisss
siiii
iissi
Or has to be:
mysqli_stmt_bind_param($stmt, 'sissssiiiiiissi ....
The same for variables and field declaration. I’m putting 3 in 3 in each row for everything, to give to count easier and visualize the lack of some variable etc...
$sql = "INSERT INTO tabela(
campo1, campo2, campo3,
campo4, campo5, campo6 ....
Only the values
that I’m putting 10 out of 10:
VALUES
(
?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ....
In the case of the error in question, I have already checked a million times, so I know that nothing is missing, everything has 138oooo!! (:/) So I think there must be some mistake in the identation, because there are spaces and line breaks too...
The error is as follows:
"Number of Elements in type Definition string doesn’t match number of bind variables"
(This number of bind variables
are the ?, ?
, or are the ssss
. Do you have any way of knowing at least what the difference is, whether of a field or 20?)
So here in this case the question is: Might white spaces be affecting the code? How PHP interprets the whitespace inside the script (I searched, but only found explanations about the trim()
:) :/ ) ?
I think it is not the case to use Trim().. should be due to line breaks in the type definition parameter sissssiiiiiissi.. Remove invalid line breaks or other characters from this parameter.
– Daniel Omine
haha no, is that I researched about "white spaces in php" in google, and only received resulytados on the
trim()
rsrsr I’ll take the test...– gustavox
would be right to google the error message "Number of Elements in type Definition string doesn’t match number of bind variables" . Whenever you see an error message, just copy and play on google, which will give you a closer result. Usually it will fall on a link of stackoverflow kkk
– Daniel Omine
Yes, I went on all of the first page at least rsrsr almost all in the OS, but my problem was this one that you said even... because now changed the error, is recording, but -1 lines lol... I think I’ll ask another question about it if it does not solve here, but this problem that was gone after I put the #$%$%&*&
ssss
on the same line... :-D thanks! @Danielomine– gustavox
Perhaps it is better to keep the data type in variable.
– rray
Your code doesn’t allow you to write otherwise ?
– Edilson
@rray did not understand, how would do it?
– gustavox
@Danielomine Just for the record, after I removed the breaks in
ssss...
that you suggested, and I got a little something here another one there (that had nothing to do with the error of the question) worked perfectly.... thanks!– gustavox
@Edilson did not understand, but I made a comment in your reply... thanks.
– gustavox
The white spaces tbm make a difference, I’m doing some tests here.
– rray