Help with adding subcategories

As one of the steps in adding subcategories to the web video script that I’m using, I created a column in the db > table >videos juts like the one named category_id and named it sub_cat_id, then went on the add a subcategory choice in the upload form, adding lines 69 thru 78 in the following code:


<div class="wo_about_wrapper_parent">
	<div class="wo_about_wrapper">
		<div class="hero hero-overlay" style="background-color: #d84c47;">
			<div class="container">
				<h1 class="text-center">{{LANG upload_new_video}}</h1>
			</div>
		</div>
		<svg id="wave" viewBox="0 0 100 15"><path fill="#d84c47" opacity="0.5" d="M0 30 V15 Q30 3 60 15 V30z"></path><path fill="#d84c47" d="M0 30 V12 Q30 17 55 12 T100 11 V30z"></path></svg>
	</div>
</div>
<div class="col-md-2"></div>
<div class="col-md-8 pt_page_margin">
	<div class="content pt_shadow">
		<div class="col-md-12 pt_upload_vdo">
			<?php if ($pt->user->admin == 1) { ?>
				<div class="alert alert-warning">
					<h4>Just admins can see this message</h4>
					<p>Note: Your server max upload size is: <?php echo ini_get('upload_max_filesize')?>, means you can't upload files that are larger than: <?php echo ini_get('upload_max_filesize')?><br><br> If you want to increase the limit or If you can't upload large files, go to Admin Settings > Settings > Site Settings > Max upload size and increase the value, if you still can't upload large files, please contact your host provider and let them increase the upload limit and max_execution_time.</p>
				</div>
			<?php } ?>
			<div class="upload upload-video" onclick="PT_OpenUploadForm();" data-block="video-drop-zone">
				<div>
					<svg fill="currentColor" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" class="feather feather-upload"><path d="M14,13V17H10V13H7L12,8L17,13M19.35,10.03C18.67,6.59 15.64,4 12,4C9.11,4 6.6,5.64 5.35,8.03C2.34,8.36 0,10.9 0,14A6,6 0 0,0 6,20H19A5,5 0 0,0 24,15C24,12.36 21.95,10.22 19.35,10.03Z" /></svg>
					<h4>{{LANG darg_drop_video}}</h4>
					<p>{{LANG or}} {{LANG click_2choose_file}}</p>
					<button class="btn btn-main">{{LANG upload}}</button>
				</div>
			</div>
			<div class="progress hidden">
				<span class="percent">0%</span>
				<div class="progress_bar_parent">
					<div class="bar upload-progress-bar progress-bar active"></div>
				</div>
				<div class="clear"></div>
				<div class="text-center pt_prcs_vdo"></div>
			</div>

			<form action="" method="POST" id="upload-video" class="hidden">
				<input type="file" name="video" accept="video/*" class="upload-video-file">
			</form>
			<div class="fluid upload-ffmpeg-mode hidden" id="upload-form">
				<div class="col-md-12">
					<form action="" class="form-horizontal setting-panel pt_forms" method="POST">
						<div class="form-group">
							<label class="col-md-12" for="title">{{LANG video_title}}</label>
							<div class="col-md-12">
								<input id="title" name="title" type="text" placeholder="" class="form-control input-md">
								<span class="help-block">{{LANG video_title_help}}</span>
							</div>
						</div>
						<div class="form-group">
							<label class="col-md-12" for="description">{{LANG video_descritpion}}</label>
							<div class="col-md-12">
								<textarea name="description" id="description" cols="30" rows="5" class="form-control"></textarea>
							</div>
						</div>

						<div class="form-group">
							<label class="col-md-12" for="category_id">{{LANG category}}</label>
							<div class="col-md-12">
								<select name="category_id" id="category_id" class="form-control">
									<?php foreach($pt->categories as $key => $category) {?>
									<option value="<?php echo $key?>"><?php echo $category?></option>
									<?php } ?>
								</select>
							</div>
						</div>



						**<div class="form-group">**
**						<label class="col-md-12" for="sub_cat_id">{{LANG subcategories}}</label>**
**						<div class="col-md-12">**
**						<select name="sub_cat_id" id="sub_cat_id" class="form-control">**
**						<?php foreach($pt->subcategories as $key => $subcategories) {?>**
**						<option value="<?php echo $key?>"><?php echo $subcategories?></option>**
**						<?php } ?>**
**						</select>**
**						</div>**
**						</div>**



						<div class="form-group">
							<label class="col-md-12" for="tags">{{LANG tags}}</label>
							<div class="col-md-12">
								<input id="mySingleFieldTags" name="tags" type="text" placeholder="" class="form-control input-md">
								<span class="help-block">{{LANG tags_help}}</span>
							</div>
						</div>
						<div class="form-group hidden" id="video-thumnails">
							<label class="col-md-12" for="thumbnail">{{LANG thumbnail}}</label>
							<div class="col-md-12">
								<div class="fluid">
									<div class="carousel slide" id="choose-thumnail-cr" data-interval="false">
										<div class="carousel-inner">
											<div class="item active"></div>
											<div class="item"></div>
											<div class="item"></div>
											<div class="item"></div>
											<div class="item"></div>
											<div class="item"></div>
										</div>
										<div class="fluid choose-thumnail-control">
											<span class="pull-left">{{LANG video_thumbs}}</span>
											<span class="pull-right">
												<a class="btn btn-default" href="#choose-thumnail-cr" data-slide="prev">
													<i class="fa fa-caret-left"></i>
												</a>
												<a class="btn btn-default" href="#choose-thumnail-cr"  data-slide="next">
													<i class="fa fa-caret-right"></i>
												</a>
											</span>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="last-sett-btn modal-footer" style="margin: 0px -40px -10px -40px;">
							<button type="submit" id="submit-btn" class="btn btn-main setting-panel-mdbtn" disabled><svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-check-circle'><path d='M22 11.08V12a10 10 0 1 1-5.93-9.14'></path><polyline points='22 4 12 14.01 9 11.01'></polyline></svg> {{LANG publish}}</button>
						</div>
						<input type="hidden" name="video-location" id="video-location" value="">
						<input type="hidden" name="video-thumnail" id="video-thumnail" value="">
					</form>
				</div>
			</div>
			<div class="clear"></div>
		</div>
		<div class="clear"></div>
	</div>
</div>
<div class="col-md-2"></div>

Can you spot anything wrong with what I’ve added?
Any help will be appreciated.

No, I can’t see anything wrong with it.

With what, specifically?

Thank you for looking that over. I’m trying to determine if the changes I made are incorrect code, in trying to eliminate possible reasons why the subcategories don’t appear. The other file code I made changes to is below. I added lines 63 thru 69, and line 101. Can you please tell me if the code there looks correct?

<?php
if (IS_LOGGED == false || $pt->config->upload_system != 'on') {
    $data = array(
        'status' => 400,
        'error' => 'Not logged in'
    );
    echo json_encode($data);
    exit();
} else if ($pt->config->ffmpeg_system != 'on') {
    $data = array(
        'status' => 402
    );
    echo json_encode($data);
    exit();
} else {
    $getID3    = new getID3;
    $featured  = ($user->is_pro == 1) ? 1 : 0;
    $filesize  = 0;
    $error     = false;
    $request   = array();
    $request[] = (empty($_POST['title']) || empty($_POST['description']));
    $request[] = (empty($_POST['tags']) || empty($_POST['video-thumnail']));
    if (in_array(true, $request)) {
        $error = $lang->please_check_details;
    } else if (empty($_POST['video-location'])) {
        $error = $lang->video_not_found_please_try_again;
    } else {
        $request   = array();
        $request[] = (!in_array($_POST['video-location'], $_SESSION['uploads']['videos']));
        $request[] = (!in_array($_POST['video-thumnail'], $_SESSION['uploads']['images']));
        $request[] = (!file_exists($_POST['video-location']));
        if (in_array(true, $request)) {
            $error = $lang->error_msg;
        }
    }
    if (empty($error)) {
        $file     = $getID3->analyze($_POST['video-location']);
        $duration = '00:00';
        if (!empty($file['playtime_string'])) {
            $duration = PT_Secure($file['playtime_string']);
        }
        if (!empty($file['filesize'])) {
            $filesize = $file['filesize'];
        }
        $video_res = (!empty($file['video']['resolution_x'])) ? $file['video']['resolution_x'] : 0;
        $video_id        = PT_GenerateKey(15, 15);
        $check_for_video = $db->where('video_id', $video_id)->getValue(T_VIDEOS, 'count(*)');
        if ($check_for_video > 0) {
            $video_id = PT_GenerateKey(15, 15);
        }
        $thumbnail = PT_Secure($_POST['video-thumnail'], 0);
        if (file_exists($thumbnail)) {
            $upload = PT_UploadToS3($thumbnail);
        }
        $category_id = 0;
        $convert     = true;
        $thumbnail   = substr($thumbnail, strpos($thumbnail, "upload"), 120);
        if (!empty($_POST['category_id'])) {
            if (in_array($_POST['category_id'], array_keys($categories))) {
                $category_id = PT_Secure($_POST['category_id']);
            }

         **$sub_cat_id = 0;**
**		$convert     = true;**
**		$thumbnail   = substr($thumbnail, strpos($thumbnail, "upload"), 120);**
**		if (!empty($_POST['sub_cat_id'])) {**
**		if (in_array($_POST['sub_cat_id'], array_keys($subcategories))) {**
**		$sub_cat_id = PT_Secure($_POST['sub_cat_id']);**
**            }**
**        }**

        $link_regex = '/(http\:\/\/|https\:\/\/|www\.)([^\ ]+)/i';
        $i          = 0;
        preg_match_all($link_regex, PT_Secure($_POST['description']), $matches);
        foreach ($matches[0] as $match) {
            $match_url            = strip_tags($match);
            $syntax               = '[a]' . urlencode($match_url) . '[/a]';
            $_POST['description'] = str_replace($match, $syntax, $_POST['description']);
        }
        $video_privacy = 0;
        if (!empty($_POST['privacy'])) {
            if (in_array($_POST['privacy'], array(0, 1, 2))) {
                $video_privacy = PT_Secure($_POST['privacy']);
            }
        }
        $age_restriction = 1;
        if (!empty($_POST['age_restriction'])) {
            if (in_array($_POST['age_restriction'], array(1, 2))) {
                $age_restriction = PT_Secure($_POST['age_restriction']);
            }
        }
        $data_insert = array(
            'video_id' => $video_id,
            'user_id' => $user->id,
            'title' => PT_Secure($_POST['title']),
            'description' => PT_Secure($_POST['description']),
            'tags' => PT_Secure($_POST['tags']),
            'duration' => $duration,
            'video_location' => '',
            'category_id' => $category_id,
            **'sub_cat_id' => $sub_cat_id,**
            'thumbnail' => $thumbnail,
            'time' => time(),
            'registered' => date('Y') . '/' . intval(date('m')),
            'featured' => $featured,
            'converted' => '2',
            'size' => $filesize,
            'privacy' => $video_privacy,
            'age_restriction' => $age_restriction
        );
        if ($pt->config->approve_videos == 'on' && !PT_IsAdmin()) {
            $data_insert['approved'] = 0;
        }
        $insert      = $db->insert(T_VIDEOS, $data_insert);
        if ($insert) {
            $data = array(
                'status' => 200,
                'video_id' => $video_id,
                'link' => PT_Link("watch/$video_id")
            );
            ob_end_clean();
            header("Content-Encoding: none");
            header("Connection: close");
            ignore_user_abort();
            ob_start();
            header('Content-Type: application/json');
            echo json_encode($data);
            $size = ob_get_length();
            header("Content-Length: $size");
            ob_end_flush();
            flush();
            session_write_close();
            if (is_callable('fastcgi_finish_request')) {
                fastcgi_finish_request();
            }
            $ffmpeg_b                   = $pt->config->ffmpeg_binary_file;
            $filepath                   = explode('.', $_POST['video-location'])[0];
            $time                       = time();
            $full_dir                   = str_replace('ajax', '/', __DIR__);

            $video_output_full_path_240 = $full_dir . $filepath . "_240p_converted.mp4";
            $video_output_full_path_360 = $full_dir . $filepath . "_360p_converted.mp4";
            $video_output_full_path_480 = $full_dir . $filepath . "_480p_converted.mp4";
            $video_output_full_path_720 = $full_dir . $filepath . "_720p_converted.mp4";
            $video_output_full_path_1080 = $full_dir . $filepath . "_1080p_converted.mp4";
            $video_output_full_path_2048 = $full_dir . $filepath . "_2048p_converted.mp4";
            $video_output_full_path_4096 = $full_dir . $filepath . "_4096p_converted.mp4";

            $video_file_full_path       = $full_dir . $_POST['video-location'];

			$watermark_image_full_path = "watermark.png";

            //$shell     = shell_exec("$ffmpeg_b -y -i $video_file_full_path -i watermark.png -filter_complex 'overlay=10:10' -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=426:-2 -crf 26 $video_output_full_path_240 2>&1");
		    $ffmpegCommand =''.$ffmpeg_b.' -y -i '.$video_file_full_path.' -i '.$watermark_image_full_path.' -filter_complex "overlay=10:10,scale=426:-2" -vcodec libx264 -preset '.$pt->config->convert_speed.' -crf 26 '.$video_output_full_path_240.' 2>&1';
			$shell     = shell_exec($ffmpegCommand);


            $upload_s3 = PT_UploadToS3($filepath . "_240p_converted.mp4");
            $db->where('id', $insert);
            $db->update(T_VIDEOS, array(
                'converted' => 1,
                '240p' => 1,
                'video_location' => $filepath . "_240p_converted.mp4"
            ));

            if ($video_res >= 640 || $video_res == 0) {
                //$shell        = shell_exec("$ffmpeg_b -y -i $video_file_full_path  -i watermark.png -filter_complex 'overlay=10:10' -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=640:-2 -crf 26 $video_output_full_path_360 2>&1");
				$ffmpegCommand =''.$ffmpeg_b.' -y -i '.$video_file_full_path.' -i '.$watermark_image_full_path.' -filter_complex "overlay=10:10,scale=640:-2" -vcodec libx264 -preset '.$pt->config->convert_speed.' -crf 26 '.$video_output_full_path_360.' 2>&1';
				$shell     = shell_exec($ffmpegCommand);

                $upload_s3                  = PT_UploadToS3($filepath . "_360p_converted.mp4");
                $db->where('id', $insert);
                $db->update(T_VIDEOS, array(
                    '360p' => 1,
                ));
            }

            if ($video_res >= 854 || $video_res == 0) {
                //$shell     = shell_exec("$ffmpeg_b -y -i $video_file_full_path -i watermark.png -filter_complex 'overlay=10:10' -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=854:-2 -crf 26 $video_output_full_path_480 2>&1");
				$ffmpegCommand =''.$ffmpeg_b.' -y -i '.$video_file_full_path.' -i '.$watermark_image_full_path.' -filter_complex "overlay=10:10,scale=854:-2" -vcodec libx264 -preset '.$pt->config->convert_speed.' -crf 26 '.$video_output_full_path_480.' 2>&1';
				$shell     = shell_exec($ffmpegCommand);

                $upload_s3 = PT_UploadToS3($filepath . "_480p_converted.mp4");
                $db->where('id', $insert);
                $db->update(T_VIDEOS, array(
                    '480p' => 1
                ));
            }

            if ($video_res >= 1280 || $video_res == 0) {
                //$shell     = shell_exec("$ffmpeg_b -y -i $video_file_full_path  -i watermark.png -filter_complex 'overlay=10:10' -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=1280:-2 -crf 26 $video_output_full_path_720 2>&1");
				$ffmpegCommand =''.$ffmpeg_b.' -y -i '.$video_file_full_path.' -i '.$watermark_image_full_path.' -filter_complex "overlay=10:10,scale=1280:-2" -vcodec libx264 -preset '.$pt->config->convert_speed.' -crf 26 '.$video_output_full_path_720.' 2>&1';
				$shell     = shell_exec($ffmpegCommand);

                $upload_s3 = PT_UploadToS3($filepath . "_720p_converted.mp4");
                $db->where('id', $insert);
                $db->update(T_VIDEOS, array(
                    '720p' => 1
                ));
            }

            if ($video_res >= 1920 || $video_res == 0) {
                //$shell     = shell_exec("$ffmpeg_b -y -i $video_file_full_path  -i watermark.png -filter_complex 'overlay=10:10' -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=1920:-2 -crf 26 $video_output_full_path_1080 2>&1");
				$ffmpegCommand =''.$ffmpeg_b.' -y -i '.$video_file_full_path.' -i '.$watermark_image_full_path.' -filter_complex "overlay=10:10,scale=1920:-2" -vcodec libx264 -preset '.$pt->config->convert_speed.' -crf 26 '.$video_output_full_path_1080.' 2>&1';
				$shell     = shell_exec($ffmpegCommand);

                $upload_s3 = PT_UploadToS3($filepath . "_1080p_converted.mp4");
                $db->where('id', $insert);
                $db->update(T_VIDEOS, array(
                    '1080p' => 1
                ));
            }

            if ($video_res >= 2048) {
                //$shell     = shell_exec("$ffmpeg_b -y -i $video_file_full_path  -i watermark.png -filter_complex 'overlay=10:10' -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=2048:-2 -crf 26 $video_output_full_path_2048 2>&1");
				$ffmpegCommand =''.$ffmpeg_b.' -y -i '.$video_file_full_path.' -i '.$watermark_image_full_path.' -filter_complex "overlay=10:10,scale=2048:-2" -vcodec libx264 -preset '.$pt->config->convert_speed.' -crf 26 '.$video_output_full_path_2048.' 2>&1';
				$shell     = shell_exec($ffmpegCommand);

                $upload_s3 = PT_UploadToS3($filepath . "_2048p_converted.mp4");
                $db->where('id', $insert);
                $db->update(T_VIDEOS, array(
                    '2048p' => 1
                ));
            }

            if ($video_res >= 3840) {
                //$shell     = shell_exec("$ffmpeg_b -y -i $video_file_full_path  -i watermark.png -filter_complex 'overlay=10:10' -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=3840:-2 -crf 26 $video_output_full_path_4096 2>&1");
				$ffmpegCommand =''.$ffmpeg_b.' -y -i '.$video_file_full_path.' -i '.$watermark_image_full_path.' -filter_complex "overlay=10:10,scale=3840:-2" -vcodec libx264 -preset '.$pt->config->convert_speed.' -crf 26 '.$video_output_full_path_4096.' 2>&1';
				$shell     = shell_exec($ffmpegCommand);

                $upload_s3 = PT_UploadToS3($filepath . "_4096p_converted.mp4");
                $db->where('id', $insert);
                $db->update(T_VIDEOS, array(
                    '4096p' => 1
                ));
            }


            if (file_exists($_POST['video-location'])) {
                unlink($_POST['video-location']);
            }

            if (!empty($_SESSION['uploads']['images'])) {
                if (is_array($_SESSION['uploads']['images'])) {
                    foreach ($_SESSION['uploads']['images'] as $key => $file) {
                        if ($thumbnail == $file) {
                            unset($_SESSION['uploads']['images'][$key]);
                        } else {
                            //@unlink($file);
                        }
                    }
                    $_SESSION['uploads']['images'] = array();
                }
            }

            pt_push_channel_notifiations($video_id);
            $_SESSION['uploads'] = array();
            exit();
        }
    } else {
        $data = array(
            'status' => 400,
            'message' => $error_icon . $error
        );
    }
}


Your first code to display the drop-down iterates through $pt->subcategories - have you added some code to populate that?

I had a quick look through what I assume to be those lines - you didn’t mark them this time and it’s too much of a pain to try to count lines inside a scrolling box on a forum page. Nothing jumped out, but if the issue is that they don’t appear in the drop-down, then this bit isn’t really relevant as this deals with storing them rather than displaying them.

Much thanks for looking over my posting and replying. I went back and marked those lines.

Regarding 'have I added some code to populate that?" I have added a column in the ‘videos’ table, in the db, identical to the category_id column, but named it sub_cat_id. And then I added the $subcategories code, below the $categories code:

<?php
$categories = array(
    '1' => 'Group1',
    '2' => 'Group2',
    '3' => 'Group3'

);


$subcategories = array(
    '4' => 'Film & Animation',
    '5' => 'Cars & Vehicles',
    '6' => 'Music',
    '7' => 'Pets & Animals',
    '8' => 'Sports',
    '9' => 'Travel & Events',
    '10' => 'Gaming',
    '11' => 'People & Blogs',
    '12' => 'Comedy',
    '13' => 'Entertainment',
    '14' => 'News & Politics',
    '15' => 'How-to & Style',
    '16' => 'Non-profits & Activism'
);


... etc.
?>

Does that look correct?

And then I added some code to the submit_video.php file like so:

<?php
if (IS_LOGGED == false || $pt->config->upload_system != 'on') {
    $data = array('status' => 400, 'error' => 'Not logged in');
    echo json_encode($data);
    exit();
}
$getID3   = new getID3;
$featured = ($user->is_pro == 1) ? 1 : 0;
$filesize = 0;

if (empty($_POST['title']) || empty($_POST['description']) || empty($_POST['tags']) || empty($_FILES['thumbnail'])) {
    $error = $lang->please_check_details;
}
if (empty($_POST['video-location'])) {
    $error = $lang->video_not_found_please_try_again;
}

if (!empty($_FILES['thumbnail']['tmp_name'])) {
    if ($_FILES['thumbnail']['size'] > $pt->config->max_upload) {
        $max   = pt_size_format($pt->config->max_upload);
        $error = $lang->file_is_too_big .": $max";
    }
}

if (empty($error)) {
    $file     = $getID3->analyze($_POST['video-location']);
    $duration = '00:00';
    if (!empty($file['playtime_string']) ) {
        $duration = PT_Secure($file['playtime_string']);
    }

    if (!empty($file['filesize'])) {
        $filesize = $file['filesize'];
    }

    $video_id        = PT_GenerateKey(15, 15);
    $check_for_video = $db->where('video_id', $video_id)->getValue(T_VIDEOS, 'count(*)');
    if ($check_for_video > 0) {
        $video_id = PT_GenerateKey(15, 15);
    }
    $thumbnail = 'upload/photos/thumbnail.jpg';
    if (!empty($_FILES['thumbnail']['tmp_name'])) {
        $file_info   = array(
            'file' => $_FILES['thumbnail']['tmp_name'],
            'size' => $_FILES['thumbnail']['size'],
            'name' => $_FILES['thumbnail']['name'],
            'type' => $_FILES['thumbnail']['type'],
            'crop' => array(
                'width' => 1076,
                'height' => 604
            )
        );
        $file_upload = PT_ShareFile($file_info);
        if (!empty($file_upload['filename'])) {
            $thumbnail = PT_Secure($file_upload['filename'], 0);
        }
    }
    $category_id = 0;
    if (!empty($_POST['category_id'])) {
        if (in_array($_POST['category_id'], array_keys($categories))) {
            $category_id = PT_Secure($_POST['category_id']);
        }
    }


        **$sub_cat_id = 0;**
**	    if (!empty($_POST['sub_cat_id'])) {**
**	        if (in_array($_POST['sub_cat_id'], array_keys($subcategories))) {**
**	            $sub_cat_id = PT_Secure($_POST['sub_cat_id']);**
**	        }**
**    }**





    $link_regex = '/(http\:\/\/|https\:\/\/|www\.)([^\ ]+)/i';
    $i          = 0;
    preg_match_all($link_regex, PT_Secure($_POST['description']), $matches);
    foreach ($matches[0] as $match) {
        $match_url           = strip_tags($match);
        $syntax              = '[a]' . urlencode($match_url) . '[/a]';
        $_POST['description'] = str_replace($match, $syntax, $_POST['description']);
    }
    $video_privacy = 0;
    if (!empty($_POST['privacy'])) {
        if (in_array($_POST['privacy'], array(0, 1, 2))) {
            $video_privacy = PT_Secure($_POST['privacy']);
        }
    }
    $age_restriction = 1;
    if (!empty($_POST['age_restriction'])) {
        if (in_array($_POST['age_restriction'], array(1, 2))) {
            $age_restriction = PT_Secure($_POST['age_restriction']);
        }
    }
    $data_insert = array(
        'video_id' => $video_id,
        'user_id' => $user->id,
        'title' => PT_Secure($_POST['title']),
        'description' => PT_Secure($_POST['description']),
        'tags' => PT_Secure($_POST['tags']),
        'duration' => $duration,
        'video_location' => PT_Secure($_POST['video-location'], 0),
        'category_id' => $category_id,
        **'sub_cat_id' => $sub_cat_id,**
        'thumbnail' => $thumbnail,
        'time' => time(),
        'registered' => date('Y') . '/' . intval(date('m')),
        'featured' => $featured,
        'size' => $filesize,
        'privacy' => $video_privacy,
        'age_restriction' => $age_restriction
    );
    if ($pt->config->approve_videos == 'on' && !PT_IsAdmin()) {
        $data_insert['approved'] = 0;
    }
    $insert      = $db->insert(T_VIDEOS, $data_insert);
    if ($insert) {
        $data = array(
            'status' => 200,
            'video_id' => $video_id,
            'link' => PT_Link("watch/$video_id")
        );
        pt_push_channel_notifiations($video_id);
    }
}
else {
    $data = array(
        'status' => 400,
        'message' => $error_icon . $error
    );
}
?>

does that look correct?

Well, it all looks correct on the surface.

So, to clarify, are you saying that the problem is the extra drop-down does appear on your form, but there are no options inside it? Or does the drop-down not appear at all on the form? Or does that all work, but when the video is saved, the selected value for the sub-cat is not stored?

If it’s the first of those, in this code:

<?php foreach($pt->subcategories as $key => $subcategories) {?>**

is there something in $pt->subcategories to iterate through? Is that populated in the PHP code that you showed in the latest post, where the array is created, or is there somewhere else that needs to populate it as it seems to be part of the $pt object?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.