Well, i edited it a bit, and it works. But now I'm trying to pull the category name of each image, and insert that as the keyword, instead of the image name. I got it to the point where it worked, but only for 1 image at a time. I have over 200,000 images, so that just won't work.
Here's what I'm using:
<?php
define('ROOT_PATH', '/home/*********/public_html/');
include(ROOT_PATH.'config.php');
include(ROOT_PATH.'includes/db_mysql.php');
include(ROOT_PATH.'includes/constants.php');
$site_db = new Db($db_host, $db_user, $db_password, $db_name) OR die("Keine Verbindung zum Datenbankserver.");
$sql = "SELECT image_id, cat_id, image_name, image_description, image_keywords, image_media_file
FROM ".IMAGES_TABLE."
WHERE image_keywords = ''";
$result = $site_db->query($sql);
while ($row = $site_db->fetch_array($result)){
$image_id = $row['image_id'];
$cat_id = $row['cat_id'];
$image_name = $row['image_name'];
$image_description = $row['image_description'];
$image_keywords = $row['image_keywords'];
$image_media_file = $row['image_media_file'];
$sql2 = "SELECT cat_id, cat_name
FROM ".CATEGORIES_TABLE."
WHERE cat_id = $cat_id";
$result2 = $site_db->query($sql2);
while ($row = $site_db->fetch_array($result2)){
$new_keywords = $row['cat_name'];
}
echo "Image ID: ".$image_id."<br>\n";
echo "Image Name: ".$image_name."<br>\n";
echo "Description: ".$image_description."<br>\n";
echo "Keywords: ".$new_keywords."<br>\n";
echo "Filename: ".$image_media_file."<br>\n";
echo "<br><hr>\n";
$sql = "UPDATE ".IMAGES_TABLE." SET image_keywords = '$new_keywords' WHERE image_id = '$image_id'";
$result = mysql_query($sql) OR die("Fehler beim Schreiben in Tabelle.");
}
@mysql_close($site_db);
?>