Jump to content

Recommended Posts

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.

 

Link to comment
https://forums.phpfreaks.com/topic/301527-hiding-a-channel-but-not-a-category/
Share on other sites

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.

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.

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 by ginerjm

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.

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!
}

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.

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. 

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?

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

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']}' />";
  • 2 weeks later...

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.