I was very carful to copy try the posted code. Sadly, I get two errors:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/www/Chris/images/keywords.php on line 55
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/www/Chris/images/keywords.php on line 60
So it doesn't these lines:
list($Name) = mysql_fetch_row($result);
while (list($Name) = mysql_fetch_row($result)){
Maybe the code was obfuscated by not using the BBCode? Did I miss something?
[b]UPDATE:
It was a simple bug. I just didn't see it too quickly. Must be the lack of sleep. Here is the corrected script:[/b]
[code]<?php
/**************************************************************************
*
* 4images - A Web Based Image Gallery Management System
* ----------------------------------------------------------------
*
* File: my_keywords.php
* Copyright: (C) 2002 Mathias Kaufberger
* Email: m.kaufberger@gmx.de
* Web: -
* Scriptversion: 1.0
*
* Never released without support from: Jan Sorgalla
*
**************************************************************************
*
* Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-
* bedingungen (Lizenz.txt) für weitere Informationen.
* ---------------------------------------------------------------
* This script is NOT freeware! Please read the Copyright Notice
* (Licence.txt) for further information.
*
*************************************************************************/
/* Allgemeine Daten fuer die Datenbankanbindung und direkter Connect zur Datenbank.
Nach Einbindung dieses Segments kann direkt mit MySQL-Befehlen auf die Datenbank zugegriffen werden.*/
/* Datenbankserver - In der Regel die IP */
$db_server = "localhost";
/* Datenbankname */
$db_name = "database_name";
/* Datenbankuser */
$db_user = "database_user";
/* Datenbankpasswort */
$db_password = "database_password";
/* mysql_connect (PHP 3, PHP 4 )
mysql_connect -- Open a connection to a MySQL Server
mysql_db_query() selects a database and executes a query on it.
If the optional link identifier isn't specified, the function will try to find an open link to
the MySQL server and if no such link is found it'll try to
create one as if mysql_connect() was called with no arguments.
*/
$db = @MYSQL_CONNECT($db_server,$db_user,$db_password);
/* mysql_db_query PHP 3, PHP 4 )
mysql_db_query -- Send a MySQL query */
$result = mysql_db_query( $db_name,"SELECT `image_keywords` FROM `4images_images` WHERE 1 order by `image_keywords` DESC");
/* mysql_fetch_row (PHP 3, PHP 4 )
mysql_fetch_row -- Get a result row as an enumerated array */
list($Name) = mysql_fetch_row($result);
// create a new array
$array = array();
/* Diese Funktion liefert TRUE, wenn eine Variable nicht definiert, leer oder gleich 0 ist ansonsten FALSE. empty (unknown) empty -- Determine whether a variable is set */
while (list($Name) = mysql_fetch_row($result)){
if(!empty($Name)){ // explode (PHP 3, PHP 4 ) explode -- Split a string by string
$explode_array = explode(" ",$Name);
for($x=0;$x<count($explode_array);$x++){
// shift into the new array
$temp = $explode_array[$x];
// strtolower (PHP 3, PHP 4 )
// strtolower -- Make a string lowercase convert into
$array[] = strtolower($temp);
//$array[] = $explode_array[$x];
}
}
}
/* array_unique (PHP 4 >= 4.0.1)
array_unique -- Removes duplicate values from an array*/
$array1 = array_unique($array);
/* sort (PHP 3, PHP 4 )sort -- Sort an array */
sort($array1,SORT_REGULAR);
/* for test reasons */
//echo "<b>Sorted Keywords:</b><br>";
echo implode(",",$array1);
?>