I’m trying to modify a web script (that I didn’t write).
The buy-video.php has this array:
“`
// add data to paid table
$insert_buy = $db->insert(‘u_paid_videos’, [
‘id_user’ => $user_id,
‘video_play_price’ => (string)$video_cost_new,
‘id_video’ => $video_id,
‘user_id_uploaded’ => $video->user_id, // the user who uploaded the video
‘video_title’ => $video->title, // storing the title
‘earned_amount’ => $up_amount,
‘time’ => $time_start,
‘short_id’ => $video->short_id,
‘session_key’ => $_SESSION[‘session_key’]
]);
I’ve attempted to replace it with this:
“`
// add data to table
$insert_buy = $db->insert(‘videos_transactions’, [
‘user_id’ => $video->user_id,
‘paid_id’ => $user_id,
‘video_id’ => $video_id,
‘amount’ => $video_cost_new,
‘admin_com’ => $uploader_amount,
‘time’ => $time_start,
‘type’ => ‘rent’,
‘session_key’ => $_SESSION[‘session_key’]
]);
without success, meaning that the user can proceed with a purchase of a video, and the ‘videos_transactions’ table populates, but no video player or video appears on the paid-videos page.
When I add this back in (to the buy-video.php):
“`
// add data to paid table
$insert_buy = $db->insert(‘u_paid_videos’, [
‘id_user’ => $user_id,
‘id_video’ => $video_id,
‘session_key’ => $_SESSION[‘session_key’]
]);
And re-test, the purchase proceeds and player and video appear on paid-videos page, (and both the ‘videos_transactions’ and the ‘u_paid_videos’ populate).
In paid-videos.php file is this:
`$get_videos = $db->rawQuery(“SELECT DISTINCT(v.id), v.* FROM u_paid_videos AS upv LEFT JOIN ” . T_VIDEOS . ” AS v ON (upv.id_video = v.id) WHERE upv.id_user = {$user->id} AND upv.session_key = ‘{$_SESSION[‘session_key’]}’ ORDER BY upv.id DESC”);
when I comment this out, the video purchase doesn’t proceed to the paid-videos page at all.
I tried to replace that with this, without success:
`$get_videos = $db->rawQuery(“SELECT DISTINCT(v.id), v.* FROM videos_transactions AS vt LEFT JOIN ” . T_VIDEOS . ” AS v ON (vt.video_id = v.id) WHERE vt.user_id = {$user->id} AND vt.session_key = ‘{$_SESSION[‘session_key’]}’ ORDER BY vt.id DESC”);
without success means, the video purchase doesn’t proceed to the paid-videos page at all.
So, I’m guessing this adds the purchase info into the ”u_paid_videos’ table:
“`
// add data to paid table
$insert_buy = $db->insert(‘u_paid_videos’, [
‘id_user’ => $user_id,
ETC.
and this pulls the info out of the ”u_paid_videos ‘ table, to proceed with dsiplaying the video?
“`$get_videos = $db->rawQuery(“SELECT DISTINCT(v.id), v.* FROM u_paid_videos…etc.
Does that sound right?
If so, how can I get the web script to instead work with:
“`
// add data to table
$insert_buy = $db->insert(‘videos_transactions’, [
‘user_id’ => $video->user_id,
‘paid_id’ => $user_id,
ETC…
and this:
“`$get_videos = $db->rawQuery(“SELECT DISTINCT(v.id), v.* FROM videos_transactions AS vt…ETC
Or what am I missing? Any guidance is appreciated