Reputation: 29
I recently updated the server on which I work. I have got an error:
"Warning: array_flip() expects parameter 1 to be array, null given in..."
Does someone know how to fix it?
Here is a part of PHP code:
function redirectWrongDep($url) {
$deps = @getDepsByIdUrl($url);
$depsFlip = array_flip($deps);
if ($_GET['dep'] && !in_array($_GET['dep'], $depsFlip)) { header('Location:'.URL);
exit();
}
}
function getDepsByIdUrl($url) {
$sql = "SELECT ws_flash_departement.nom,ws_flash_departement.id_departement FROM ws_flash_departement WHERE ws_flash_departement.no_resultats != 0 AND ws_flash_departement.id_departement IN (SELECT url_departement.id_departement FROM url_departement WHERE url_departement.id_url=" . $url . ") ORDER BY nom ASC";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
$deps[$row["id_departement"]]=utf8_encode($row["nom"]);
}
mysql_free_result($result);
return $deps;
}
Upvotes: -4
Views: 3018
Reputation: 324
most likely you updated to an server where magic quotes is set on off
This id because something is returning the value false
or not returning true
or 1
so debug the code .you are not suplling anything too the array_flip()
you have to supply array
example:
$arr = array("a" => 3, "b" => 1, "c" => 2);
$arr = array_flip($arr);
print_r($arr);
Upvotes: 1
Reputation: 1114
Check this manual:
http://php.net/manual/en/function.array-flip.php
Eg.
$trans = array("a" => 1, "b" => 1, "c" => 2);
$trans = array_flip($trans);
print_r($trans);
Upvotes: 0
Reputation: 2807
array_flip takes an array as first parameter and you give nothing...
PS: Maybe with some lines of code, I could give you a more precise answer
Upvotes: 0