Search problems... :(

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A form passes variable "$chiave" to result.php

RESULT.PHP CODE:

--------------------------------------------------------------------------------

<?
include("top_foot.inc.php");
include("config.inc.php");
top();

$db = mysql_connect($db_host, $db_user, $db_password);
if ($db == FALSE)
die ("Error, Verify settings in config.inc.php");
mysql_select_db($db_name, $db)
or die ("Can't select database. Verify settings in config.inc.php");

$keys = explode (" ", $_POST ["chiave"]);

$query = "";

foreach ($Keys as $single_word)
{$single_word = trim($single_word);
if ($single_word != "")
$query .= "titolo LIKE '%$single_word%' OR testo LIKE '%$single_word%' OR autore LIKE '%$single_word%' OR ";
}

$query .= "'0'";

$query = "SELECT id, titolo, data FROM news WHERE " . $query;

$result = mysql_query($query, $db);
while ($row = mysql_fetch_array($result))
{ echo "<a href=\"view.php?id=$row[id]\">" . date("j/n/y", $row[data]) . " - $row[titolo]</a><br>"; }

foot();
?>

--------------------------------------------------------------------------------

Everything goes right till
foreach ($Keys as $single_word) 
that RETURNS:

Warning: Invalid argument supplied for foreach() in c:\programmi\apache group\apache\test\prova\result.php on line 

Do U know why?
Thanks in advance
Marco

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux