Jump to content

executing mysql LIKE query

Go to solution Solved by requinix,

Recommended Posts

I'm trying to execute this query

$stmt = $mysqli->prepare("SELECT streamer,content,provider
      FROM  evento,canali
      WHERE canali.id=evento.idcanale
      AND evento.titolo LIKE '%?%' OR evento.sottotitolo LIKE '%?%'
      AND evento.datainizio=2013-02-21;");
but I get this error Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement. 
but to me it seems like the number are the same,  you can see how I prepared the statement with 2 arguments to define, and then I passe 2 arguments to add_param, what I'm getting wrong?


some has some ideas?
daniele New php-forum User
rank_1.png   Posts: 2 Joined: Fri May 03, 2013 6:48 pm




Link to comment
Share on other sites

  • Solution

I am so not inclined to help you since the only effort you've shown here is that you can copy/paste entire posts from another forum. You didn't even bother to copy only the text.


But it's a very easy answer so I will anyway.


Bound variables don't work like simple string replacements. If you want to LIKE a field against a bound string then the string has to be the entire expression - %s and all.

$tok = "%" . $tok . "%";
AND evento.titolo LIKE ? OR evento.sottotitolo LIKE ?
Edited by requinix
Link to comment
Share on other sites

sorry fot he copy/paste but I posted a couple of days ago on the other forum and nobody answered, and since I couldn't find I answer I changed forum!

thanks for the answer, now it seems like it's working

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.