问题
So I made this script that should fetch an array using mysqli_fetch_array
and mysqli_query
it all works fine, and no error shows up, but then after I change something, using another function, for example, If I change the mood, nickname or whatever, it shows an error
Warning: join(): Invalid arguments passed in Main.php on line 526
Iv'e been trying to fix this using a while loop
and the same thing happens
$info = mysqli_fetch_array(mysqli_query($con, "SELECT id, nickname, mood, credits, colour, curhead, curface, curneck, curbody, curhands, curfeet, curflag, curphoto, rank * 146 FROM `sync_users` WHERE id='" . mysqli_real_escape_string($con, $raw[5]) . "';"), MYSQLI_ASSOC);
$client->sendPacket("%xt%gp%-1%" . join("|", $info) . "%");
print str_replace('Array', '', print_r($info, true));
I tried asking a few other friends who knew php well and they were unable to give me a solution as well.
回答1:
One or more elements of the array isn't a string. Either cast the offending fields in the query, or pass all the fields through strval()
first.
回答2:
Here goes a lesson on basic debugging:
If a PHP function complains for the input parameters, it would be a good idea to verify these parameters. So, adding
var_dump($info);
to your code will most likely output (bool)false
Which lead us to believe that SQL query returned no rows, and so it's time to debug the query.
Hope it helps
回答3:
First of all don't use mysql_* functions because are deprecated, try PDO for example
I think that if mysqli_fetch_array
returns an empty resultset then the join
will fail because mysqli returns a FALSE
Perhaps it will be your problem
来源:https://stackoverflow.com/questions/18374881/invalid-arguments-passed-join