My name is Hamza, I’m a French student and a beginner in programmation !
So I’m doing a project, a personal one and it’s a kind of blog, where you can upload articles and those articles have comments and tags you know, basic. I’m stuck in a step. This step is that I want to select all my articles with entrering a tag in a search bar. I’ve done the search bar, I think that I had my articles but when I want to print then in my view I have one error : " Cannot convert value of type array to string" and I don’t understand.
EDITION : I already did the samething without the tag searching but I never seen this error…
This is going to expect a single value, not an array (assuming you’re using Cake 3.x). But getData is going to return an array.
Not sure that this is your problem, as you have shown the recherchearticle but not where that’s linked from, and you’ve said there’s a problem in your view but not specified which line it’s on.
You’re also more likely to get good responses if you include your code here (properly formatted) instead of through links to screen shots. I took the time to manually type out that one line of code, but many won’t bother; give them something they can copy-and-paste.
OK, thank you for advices, I’m going to check, and sorry I didn’t the “rules”, it’s my first time on this forum and more on forum oncerning programmation !
So I’ve checked and I think that my SQL request is good ! I did a dd on the variable and it looks well.
The problem is probably in my .ctp. Here is it :
As I said before, getData will return an array, and the form of where that you’re using won’t accept that. What exactly does your posted data look like? If it’s just a single tag, you need to extract that from the array before using it; if it’s multiple tags, you’ll likely want to use 'text_tag IN' => $text_tag.