sax Posted May 5, 2013 Share Posted May 5, 2013 HyI'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;"); $stmt->bind_param('ss',$tok,$tok); $stmt->execute(); $stmt->close(); 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?thanks daniele New php-forum User Posts: 2 Joined: Fri May 03, 2013 6:48 pm Link to comment https://forums.phpfreaks.com/topic/277647-executing-mysql-like-query/ Share on other sites More sharing options...
sax Posted May 5, 2013 Author Share Posted May 5, 2013 edit: i'm using xamp 1.8.1 like mysql server!! Link to comment https://forums.phpfreaks.com/topic/277647-executing-mysql-like-query/#findComment-1428329 Share on other sites More sharing options...
requinix Posted May 5, 2013 Share Posted May 5, 2013 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 ? Link to comment https://forums.phpfreaks.com/topic/277647-executing-mysql-like-query/#findComment-1428332 Share on other sites More sharing options...
sax Posted May 5, 2013 Author Share Posted May 5, 2013 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 https://forums.phpfreaks.com/topic/277647-executing-mysql-like-query/#findComment-1428338 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.