Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325
query("SHOW TABLES LIKE 'tbl_blog_article'"); if ($checkOldTable->num_rows == 0) { die("Error: Old table 'tbl_blog_article' not found!"); } // Step 2: Category mapping - UPDATE THESE BASED ON YOUR DATA! // Run this query to check: SELECT blog_cat, title FROM tbl_blog_article LIMIT 20; $categoryMapping = [ 1 => 'Vastu', // ← Update this 2 => 'Numerology', // ← Update this 4 => 'Astrology', // ← Update this 5 => 'Fengshui', // ← Update this 6 => 'Dream' // ← Update this ]; // Step 3: Fetch data from old table $oldBlogs = $conn->query("SELECT * FROM tbl_blog_article ORDER BY created_at DESC"); if (!$oldBlogs) { die("Error fetching old blogs: " . $conn->error); } $migrationLog[] = "Found " . $oldBlogs->num_rows . " blogs to migrate."; // Step 4: Create images directory if it doesn't exist if (!file_exists('images')) { mkdir('images', 0755, true); $migrationLog[] = "Created images/ directory"; } // Step 5: Begin migration $successCount = 0; $skipCount = 0; while ($oldBlog = $oldBlogs->fetch_assoc()) { // Skip if title or description is empty if (empty(trim($oldBlog['title'])) || empty(trim($oldBlog['description']))) { $skipCount++; $errors[] = "Skipped blog ID {$oldBlog['id']} - Empty title or description"; continue; } // Get category name from mapping $blogCat = $oldBlog['blog_cat']; if (!isset($categoryMapping[$blogCat])) { $errors[] = "Warning: Unknown category ID {$blogCat} for blog '{$oldBlog['title']}' - Using 'Astrology' as default"; $category = 'Astrology'; } else { $category = $categoryMapping[$blogCat]; } // Prepare data $title = trim($oldBlog['title']); $content = trim($oldBlog['description']); $oldImageName = trim($oldBlog['image']); $createdAt = $oldBlog['created_at']; $status = 'active'; // Handle image migration from Blog/ folder to images/ folder $newImageName = $oldImageName; if (!empty($oldImageName)) { $oldImagePath = 'Blog/' . $oldImageName; $newImagePath = 'images/' . $oldImageName; // Check if image exists in Blog/ folder if (file_exists($oldImagePath)) { // Copy image to images/ folder if (copy($oldImagePath, $newImagePath)) { $imagesMoved++; $migrationLog[] = " → Copied image: {$oldImageName}"; } else { $errors[] = "Failed to copy image: {$oldImageName}"; $imagesSkipped++; } } else { // Image doesn't exist in Blog/ folder, check if already in images/ if (file_exists($newImagePath)) { $migrationLog[] = " → Image already exists in images/: {$oldImageName}"; } else { $errors[] = "Image not found: {$oldImageName} (not in Blog/ or images/)"; $imagesSkipped++; } } } // Check if blog already exists $checkStmt = $conn->prepare("SELECT id FROM blogs WHERE title = ? AND created_at = ?"); $checkStmt->bind_param("ss", $title, $createdAt); $checkStmt->execute(); $checkResult = $checkStmt->get_result(); if ($checkResult->num_rows > 0) { $skipCount++; $migrationLog[] = "Skipped: '{$title}' (already exists)"; $checkStmt->close(); continue; } $checkStmt->close(); // Insert into new table $stmt = $conn->prepare("INSERT INTO blogs (title, content, category, image, created_at, status) VALUES (?, ?, ?, ?, ?, ?)"); $stmt->bind_param("ssssss", $title, $content, $category, $newImageName, $createdAt, $status); if ($stmt->execute()) { $successCount++; $migrationLog[] = "✓ Migrated: '{$title}' (Category: {$category})"; } else { $errors[] = "✗ Failed to migrate blog ID {$oldBlog['id']}: " . $stmt->error; } $stmt->close(); } $conn->close(); ?> Blog Migration Results

🔄 Blog Migration Results

⚠️ Category Warning: Some blogs have unknown category IDs. Check the errors below and update the category mapping in the script if needed.
Total Blogs Found: num_rows; ?>
Successfully Migrated:
Images Moved:
Skipped Blogs:
Skipped Images:
Errors:
0): ?>

✅ Migration Log

⚠️ Errors & Warnings

✅ Next Steps:
Go to Blog Management View Frontend Blog