0

I might just be too dumb to see it but here is my issue:

Code:

$stmt = $mysql->prepare("INSERT INTO projects_files (mid,filename,type) VALUES ('?','?','?')");
$stmt->bind_param('isi',$this->id,$File->filename,$File->type);

Error:

Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement

I have checked that all vars are assigned and have a value and the datatypes are all right.

Thanks in advance for help

2 Answers 2

1

Don't put the question marks in quotes. The database will quote everything appropriately.

$stmt = $mysql->prepare("INSERT INTO projects_files (mid,filename,type) VALUES (?,?,?)");
$stmt->bind_param('isi',$this->id,$File->filename,$File->type);
Sign up to request clarification or add additional context in comments.

3 Comments

My friend just showed up and told me the same :) Thanks for the help tho.
@Jenjen1324 Mark the question as answered if you've solved your problem.
I was going to but you answered so fast I had to wait another 12 minutes ;)
1

Remove the bindparam single quotes(') around the question mark(?)

$stmt = $mysql->prepare("INSERT INTO 
                     projects_files (mid,filename,type) 
                     VALUES (?,?,?)");
$stmt->bind_param('isi',$this->id,$File->filename,$File->type);

2 Comments

"isi" is the types parameter. See us2.php.net/manual/en/mysqli-stmt.bind-param.php
@CullyLarson : Oho, I forgot that sorry. Thank for your advice. I updated my answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.