Chrisj Posted July 20, 2016 Share Posted July 20, 2016 In a php video-web-script I'm using, in the (video)Upload Form I tried hiding the select-a-channel drop-down choices, essentially like this: <li><input type="hidden" name="channel" value="1"/></li> (so, that the Channel is pre-determined for the uploader/user). But, when the Channel is hidden like that, the next field box(sub-categories) in the Form, shows no choices. Apparently, in this Upload Form a Channel choice is required in order to see the sub-category choices. So, I'm trying to figure out a way to hide the channel, but somehow let the Form know that Channel has been chosen, so that the sub-category drop-down choices are available for choosing, and proceeding. Here's the code without the hidden Channel: <li style="width:240px; text-align:right;"><strong>[var.lang_select_channel]:</strong></li> <li style="width:400px; text-align:left;"> <select class="upload-video-form-input" style="width:160px;" size="1" name="channel" onchange="javascript:ahahscript.ahah('[var.base_url]/uploader.php?sub_cat='+ document.form_upload.channel.value, 'sub_change', '', 'GET', '', this);"> [var.fields_all;htmlconv=no]</select> ([var.lang_select_one])</li> <li style="width:240px; text-align:right"> </li> <li style="width:380px" class="font5_14"><strong>[var.lang_sub_categories]</strong></li> <li style="width:240px; text-align:right"><strong>[var.lang_sub_cat]: </strong></li> <li style="width:400px; text-align:left;" id="sub_change"><select class="upload-video-form-input" style="width:160px;" size="1" name="sub_cat"></select> ([var.lang_optional])</li> So, then I tried adding this to the uploader.php file: if(isset($_SESSION['channel_id'])) { echo '<input type="hidden" name="channel" value="1"> } else { echo '<select class="upload-video-form-input" name="channel" onchange="javascript:ahahscript.ahah('[var.base_url]/uploader.php?sub_cat='+ document.form_upload.channel.value, 'sub_change', '', 'GET', '', this);"> [var.fields_all;htmlconv=no]</select> '; } but got a syntax error. Any ideas regarding "hide the channel, but somehow let the Form know that Channel has been chosen, so that the sub-category drop-down choices are available for choosing" will be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
benanamen Posted July 20, 2016 Share Posted July 20, 2016 (edited) You are missing the closing quote and semicolon on your echo. Edited July 20, 2016 by benanamen Quote Link to comment Share on other sites More sharing options...
Chrisj Posted July 20, 2016 Author Share Posted July 20, 2016 Thanks for your reply. I'm not seeing what you mean. I see: '; } isn't that correct? Quote Link to comment Share on other sites More sharing options...
ginerjm Posted July 20, 2016 Share Posted July 20, 2016 You say you got a syntax error so you apparently have error checking turned on. Did you follow up on the message as to the script name and the line number giving you that error and correct it? Quote Link to comment Share on other sites More sharing options...
Chrisj Posted July 20, 2016 Author Share Posted July 20, 2016 Thanks for your message. "Parse error: syntax error, unexpected T_CLASS, expecting ',' or ';' in /home/public_html/uploader.php on line 48" line 48 is blank. The error only appears when I add: if(isset($_SESSION['channel_id'])) { echo '<input type="hidden" name="channel" value="1"> } else { echo '<select class="upload-video-form-input" name="channel" onchange="javascript:ahahscript.ahah('[var.base_url]/uploader.php?sub_cat='+ document.form_upload.channel.value, 'sub_change', '', 'GET', '', this);"> [var.fields_all;htmlconv=no]</select> '; } to line 83 Any additional help will be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
benanamen Posted July 20, 2016 Share Posted July 20, 2016 I told you exactly where the problem is and what the problem is. Your first Echo doesn't close. Quote Link to comment Share on other sites More sharing options...
Chrisj Posted July 20, 2016 Author Share Posted July 20, 2016 Thanks you for your replies. I corrected the echo close, Much appreciated. However, I still see this error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/public_html/uploader.php on line 39 and line 39 is blank. Any additional help will be appreciated. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted July 20, 2016 Share Posted July 20, 2016 (edited) Trust me - line 39 is not blank. Whatever editor you are using is not numbering things correctly. Look above and below and look for the error. You are looking in the uploader script? What is this var.base_url thingie? You wrap that in quotes once but the next thingie var.fields_all you don't. Should there be some consistency with whatever they are? Edited July 20, 2016 by ginerjm Quote Link to comment Share on other sites More sharing options...
Chrisj Posted July 20, 2016 Author Share Posted July 20, 2016 Thank you for your reply/help. Yes,I'm looking at uploader.php. Here are lines 19 thru 81 include_once ('classes/config.php'); include_once ('classes/sessions.php'); include 'uploader_conlib.php'; $config['notification_error'] = $lang_error; $page_title = $lang_upload_video; if ($_SESSION['user_id'] == "") { header("Location: $login_out_link");; die(); } $load_javascript = 1; $ahah = 1; $thickbox = 1; /////////////////////////////////////////////////////////////////////////////////////// // ADDED SPAMMER UPLOAD TRACKING LOGING // $member_uploading = $_SESSION['user_name']; $tracking_log_file = 'logs/uploader_log.txt'; $admin_email = $config['admin_notify_email']; $user_ip = mysql_escape_string($_SERVER['REMOTE_ADDR']); $referer = mysql_real_escape_string($_SERVER['HTTP_REFERER']); if ( $referer == '' ) die_spammer_alerts(); if ( !ereg ($_SERVER['SERVER_NAME'], $referer) ) die_spammer_alerts(); /////////////////////////////////////////////////////////////////////////////////////// if(isset($_SESSION['channel_id'])) { echo '<input type="hidden" name="channel" value="$_SESSION['channel_id']">'; } else { echo '<select class="upload-video-form-input" name="channel" onchange="javascript:ahahscript.ahah('[var.base_url]/uploader.php?sub_cat='+ document.form_upload.channel.value, 'sub_change', '', 'GET', '', this);"> [var.fields_all;htmlconv=no]</select>'; } Any additional help will be appreciated. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted July 20, 2016 Share Posted July 20, 2016 Is your code naturally double-spaced or are you doing that? Bad editor! Quote Link to comment Share on other sites More sharing options...
ginerjm Posted July 20, 2016 Share Posted July 20, 2016 See comments I added include_once ('classes/config.php'); include_once ('classes/sessions.php'); include 'uploader_conlib.php'; $config['notification_error'] = $lang_error; $page_title = $lang_upload_video; if ($_SESSION['user_id'] == "") { header("Location: $login_out_link");; // TWO SEMIS HERE die(); } $load_javascript = 1; $ahah = 1; $thickbox = 1; /////////////////////////////////////////////////////////////////////////////////////// // ADDED SPAMMER UPLOAD TRACKING LOGING // $member_uploading = $_SESSION['user_name']; $tracking_log_file = 'logs/uploader_log.txt'; $admin_email = $config['admin_notify_email']; $user_ip = mysql_escape_string($_SERVER['REMOTE_ADDR']); $referer = mysql_real_escape_string($_SERVER['HTTP_REFERER']); if ( $referer == '' ) die_spammer_alerts(); if ( !ereg ($_SERVER['SERVER_NAME'], $referer) ) die_spammer_alerts(); /////////////////////////////////////////////////////////////////////////////////////// if(isset($_SESSION['channel_id'])) { echo '<input type="hidden" name="channel" value="$_SESSION['channel_id']">'; // THINK YOU NEED TO WORK ON THIS } else { echo '<select class="upload-video-form-input" name="channel" onchange="javascript:ahahscript.ahah('[var.base_url]/uploader.php?sub_cat='+ document.form_upload.channel.value, 'sub_change', '', 'GET', '', this);"> [var.fields_all;htmlconv=no]</select>'; // THIS LINE IS DEFINITELY BROKEN. TOO MANY ' AND " CHARS HERE! } Quote Link to comment Share on other sites More sharing options...
Chrisj Posted July 20, 2016 Author Share Posted July 20, 2016 Thank you for looking that over. I appreciate it. I removed the one of the TWO SEMIS, thanks. Yes, I need some guidance with: "THINK YOU NEED TO WORK ON THIS" "THIS LINE IS DEFINITELY BROKEN. TOO MANY ' AND " CHARS HERE!" and with the syntax error. Any guidance you'd like to share will be welcomed. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted July 20, 2016 Share Posted July 20, 2016 It's all about the use of quotes and double quotes. You have to break up the string in to pieces or else use escape chars to avoid unintended breaks to your content. Quote Link to comment Share on other sites More sharing options...
benanamen Posted July 20, 2016 Share Posted July 20, 2016 Your code is obsolete. ereg and MySQL_* have been completely removed from PHP. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted July 20, 2016 Share Posted July 20, 2016 Well, not if he isn't up to date. For now he just has a bunch of other syntax problems and owes us some answers about certain things I asked about in his code. Quote Link to comment Share on other sites More sharing options...
Chrisj Posted July 20, 2016 Author Share Posted July 20, 2016 Thanks for your replies. The text editor is text-pad, and I'm not doing that, I'm just copying it from text-pad. Regarding "you have to break up the string in to pieces or else use escape chars to avoid unintended breaks to your content", any example you like to share will be appreciated. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted July 20, 2016 Share Posted July 20, 2016 Really? I have to teach you how to restructure a compound string? Instead of this: echo '<input type="hidden" name="channel" value="$_SESSION['channel_id']">'; Try: echo "<input type='hidden' name='channel' value='".$_SESSION['channel_id']."'>"; Note the use of the . to break it into 3 pieces so that the session var could be properly recognized. There are other ways but this is simple. Also note: When building complex strings IMHO it is better to wrap it in double guotes to enable the vars to be properly interpreted. Try this on the other problem string. What about the thingie I asked you about? What IS it? Quote Link to comment Share on other sites More sharing options...
Chrisj Posted July 20, 2016 Author Share Posted July 20, 2016 Thanks for your reply and for sharing that example. Regarding the 'thingie', I couldn't tell you what that is, I'm using this web script, and trying to modify it,I'm not the author. I'll be grateful for any additional ideas on the syntax error, thanks again Quote Link to comment Share on other sites More sharing options...
ginerjm Posted July 20, 2016 Share Posted July 20, 2016 Well if you don't know what it is how are we supposed to help you cause that is part of your string issue I think. What is that string supposed to output for you? Figure out what you want and write your own output string. Quote Link to comment Share on other sites More sharing options...
Zane Posted July 21, 2016 Share Posted July 21, 2016 Another way of adding your variables to your strings is by using { } curly braces. Note: you can only do this when your string is enclosed with double quotes " because content between single quotes doesn't get parsed. echo "<input type='hidden' name='channel' value='{$_SESSION['channel_id']}' />"; Quote Link to comment Share on other sites More sharing options...
Chrisj Posted July 24, 2016 Author Share Posted July 24, 2016 Thank you Quote Link to comment Share on other sites More sharing options...
Chrisj Posted August 6, 2016 Author Share Posted August 6, 2016 Thank you for all of your replies. I've cured the syntax error and added this to uploader.php: if(isset($_SESSION['channel_id'])) { echo '<input type="hidden" name="channel" value="1">'; } else { echo "<select class='upload-video-form-input' name='channel' onchange='javascript:ahahscript.ahah('[var.base_url]/uploader.php?sub_cat='+ document.form_upload.channel.value, 'sub_change', '', 'GET', '', this);'> [var.fields_all;htmlconv=no]</select>"; } However, I could use some assistance, please, with how to tie it into the Form code: <li style="width:240px; text-align:right;"><strong>[var.lang_select_channel]:</strong></li> <li style="width:400px; text-align:left;"> <select class="upload-video-form-input" style="width:160px;" size="1" name="channel" onchange="javascript:ahahscript.ahah('[var.base_url]/uploader.php?sub_cat='+ document.form_upload.channel.value, 'sub_change', '', 'GET', '', this);"> [var.fields_all;htmlconv=no]</select> ([var.lang_select_one])</li> <li style="width:240px; text-align:right"> </li> <li style="width:380px" class="font5_14"><strong>[var.lang_sub_categories]</strong></li> <li style="width:240px; text-align:right"><strong>[var.lang_sub_cat]: </strong></li> <li style="width:400px; text-align:left;" id="sub_change"><select class="upload-video-form-input" style="width:160px;" size="1" name="sub_cat"></select> ([var.lang_optional])</li> Any guidance with how to ultimately adjust the Form so the named the channel "1", can allow the sub-categories to populate the Form, will be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.