Forums / Cotonti / Extensions / PHP array in MySQL query??

Sean
#1 2009-10-29 03:41
Ive got a problem with an SQL query in a plugin im writing. Im trying to pass an array into a MySQL Query, but im having some problems. Every time i try the plugin in my browser, I get redirected to the Error #905 (Wrong URL) error page. No mysql error, nothing. Whats going on? Ive tried passing the array into a variable, then serializing it, ive tried converting the variable but nothing seems to work. Any ideas? Thanks.
GHengeveld
#2 2009-10-29 15:18
Serialize should do it. Please provide some of your code. Error 950 could be because you're importing a variable which doesnt hold the right datatype. As far as i know this only happens if the last parameter of sed_import is set to true.
Sean
#3 2009-10-30 01:28
It could be that im not using serialize properly. Ive never used it before, and all i know about it is what ive read on the internet :P

I should probably explain what im trying to do first. Im trying to modify the Seditio gallery plugin to display multiple galleries on the same page. So for example, /plug.php?e=gallery&f=2|4|1 will display pictures from gallery 2, 4 and 1. So what ive done is imported $f, exploded it, then looped through each gallery.

Heres the code:


Does it have something to do with sed_import do you think?
Thanks a lot for your help!
This post was edited by Kilandor (2009-10-30 02:45, 14 years ago)
Kilandor
#4 2009-10-30 02:47
The function is serialize not serialise :)

http://us.php.net/manual/en/function.serialize.php
Sean
#5 2009-10-30 03:17
ha ha yes it looks like i made a typo. I don't think this is the problem though... ive had serialize working properly when i was messing around with it before but it still wasn't working for me. How would I serialize $collections[$count]? When I tried it before, $collections['1'] out puts as s:1:"1"; which of course just gives me an SQL error. I guess i dont quite understand how serialize works.

EDIT:
I think ive found out what is causing the 905 error. After the second SQL query theres a line
sed_die(mysql_num_rows($sql_pff)==0);
which is causing it to die. should have seen this earlier. So this means that the SQL queries are failing and not finding anything....

Added 16 minutes later:

Ahh stupid me. I figured it out. The sed_import for $f was wrong, 2|3|5 is not a int. I set it to txt and now it works :)
This post was edited by Sean (2009-10-30 03:59, 14 years ago)
GHengeveld
#6 2009-10-31 01:26
Why use url.php?f=1|2|3 if you can just use url.php?f=1&f=2&f=3 ? This will make $f an array automatically so you don't need to explode it. This is de default way in which checkboxes and multiple selects get sent with the GET method.