![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/soundstudiopro.com/private_html/ |
<?php
require_once 'config/database.php';
echo "<h2>Fix Variation Titles</h2>";
try {
$pdo = getDBConnection();
// Find variations with null or empty titles
$stmt = $pdo->prepare("
SELECT
id,
track_id,
variation_index,
metadata
FROM audio_variations
WHERE title IS NULL OR title = '' OR title = 'null'
");
$stmt->execute();
$variations_to_fix = $stmt->fetchAll();
if (empty($variations_to_fix)) {
echo "<p><strong>✅ No variations with null titles found!</strong></p>";
exit;
}
echo "<p><strong>Found " . count($variations_to_fix) . " variations with null titles to fix:</strong></p>";
$fixed_count = 0;
foreach ($variations_to_fix as $variation) {
echo "<p>Fixing variation ID {$variation['id']} (Track {$variation['track_id']}, Index {$variation['variation_index']})</p>";
// Try to extract title from metadata
$metadata = json_decode($variation['metadata'], true);
$title = null;
if ($metadata) {
// Try to build title from available metadata
$titleParts = [];
if (!empty($metadata['genre'])) $titleParts[] = $metadata['genre'];
if (!empty($metadata['style'])) $titleParts[] = $metadata['style'];
if (!empty($metadata['mood'])) $titleParts[] = $metadata['mood'];
if (!empty($metadata['energy'])) $titleParts[] = $metadata['energy'];
if (!empty($titleParts)) {
$title = implode(' ', $titleParts) . ' Variation';
} else {
$title = "AI Variation " . $variation['variation_index'];
}
} else {
// Fallback to simple naming
$title = "AI Variation " . $variation['variation_index'];
}
// Update the variation title
$update_stmt = $pdo->prepare("UPDATE audio_variations SET title = ? WHERE id = ?");
$result = $update_stmt->execute([$title, $variation['id']]);
if ($result) {
echo "<p style='color: green;'>✅ Fixed: {$title}</p>";
$fixed_count++;
} else {
echo "<p style='color: red;'>❌ Failed to update variation {$variation['id']}</p>";
}
}
echo "<h3>Summary:</h3>";
echo "<p><strong>Total variations processed:</strong> " . count($variations_to_fix) . "</p>";
echo "<p><strong>Successfully fixed:</strong> {$fixed_count}</p>";
echo "<p><strong>Failed:</strong> " . (count($variations_to_fix) - $fixed_count) . "</p>";
} catch (Exception $e) {
echo "<p><strong>❌ Error:</strong> " . htmlspecialchars($e->getMessage()) . "</p>";
}
?>