![]() 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>Test Update Track API</h2>";
try {
$pdo = getDBConnection();
// Get a track to test with
$stmt = $pdo->query("
SELECT
id,
title,
description,
price,
is_public
FROM music_tracks
WHERE status = 'complete'
LIMIT 1
");
$track = $stmt->fetch();
if ($track) {
echo "<p><strong>Testing with track:</strong> " . htmlspecialchars($track['title']) . " (ID: {$track['id']})</p>";
echo "<p><strong>Current price:</strong> " . var_export($track['price'], true) . "</p>";
// Test the API update
echo "<h3>Testing API Update:</h3>";
$testData = [
'track_id' => $track['id'],
'title' => $track['title'] . ' (Updated)',
'description' => $track['description'] . ' (Updated)',
'price' => 9.99,
'is_public' => 1
];
echo "<p><strong>Data to send:</strong></p>";
echo "<pre>" . json_encode($testData, JSON_PRETTY_PRINT) . "</pre>";
// Make the API call
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'api/update_track.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($testData));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Cookie: PHPSESSID=' . session_id()
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "<p><strong>HTTP Response Code:</strong> {$httpCode}</p>";
echo "<p><strong>API Response:</strong></p>";
if ($response) {
$result = json_decode($response, true);
echo "<pre>" . json_encode($result, JSON_PRETTY_PRINT) . "</pre>";
if ($result['success']) {
// Check if the track was actually updated
$stmt = $pdo->prepare("SELECT title, description, price, is_public FROM music_tracks WHERE id = ?");
$stmt->execute([$track['id']]);
$updatedTrack = $stmt->fetch();
echo "<h4>Database After Update:</h4>";
echo "<p><strong>Title:</strong> " . htmlspecialchars($updatedTrack['title']) . "</p>";
echo "<p><strong>Description:</strong> " . htmlspecialchars($updatedTrack['description']) . "</p>";
echo "<p><strong>Price:</strong> " . var_export($updatedTrack['price'], true) . "</p>";
echo "<p><strong>Is Public:</strong> " . var_export($updatedTrack['is_public'], true) . "</p>";
}
} else {
echo "<p><strong>❌ No response from API</strong></p>";
}
} else {
echo "<p><strong>❌ No tracks found to test with</strong></p>";
}
} catch (Exception $e) {
echo "<p><strong>❌ Error:</strong> " . htmlspecialchars($e->getMessage()) . "</p>";
}
?>