Jump to content

Recommended Posts

My script works in FF, Chrome, Safari, but not IE8 or 7 ( perhaps 6, but didn't test).

I have a form where the post array is not coming through in IE, but does in FF.

 

// here is the problem, when I uncomment the print_r($order) and exit, I can see that in FF, the array shows. If I do this very same thing in IE, it only shows the first element and never gets to the query to touch the database. My theory is that if the problem is outputing the array, then maybe it is the form.

 

(line 127)

if(isset($_POST['ordersubmit'])){

 

  $order = array();

 

  $order =$_POST['order'];

 

//  print_r($order);

 

// exit;

 

 

So the form whether in a heardoc or not, sitll give the problem. Can someone tell if they know if IE handles input text boxes or arrays differently?

 

The form is on line 173 and looks like this

//code

if($isfeatured=='1'){

 

      $isfeatured='Yes';

 

      $orderrow = "<td><input type='text' name='order[$vid_id]'' size='3' value='$ordering'</td>";

 

    }else{$isfeatured='No';$orderrow='<td> </td>';}

 

$body_main.=<<<BODY

 

 

 

//Below this point is the entire file. Also attached to reference line number

<?php

 

/*  File: managevids.php

 

*  This page prints user/testimonial report as an excel file

 

*

 

*  Dependancies:  dbconnection.php,

 

*   testimonials.class.php,

 

*   functions.inc.php

 

*

 

*  Last Modified:  06-04-09

 

*

 

*/

 

 

 

//GET REQUIRED FILES

 

require_once("./dbconnection.php");

 

require_once("./testimonials.class.php");

 

require_once("./functions.inc.php");

 

 

 

function createThumb($testimonial_id){

 

  // grab filename of video

 

  $sql = "select * from testimonials where id = '$testimonial_id' limit 1";

 

  $result = mysql_query($sql) or die(mysql_error());

 

  $num_rows = mysql_num_rows($result);

 

 

 

  if($num_rows==1){

 

    while($row3 = mysql_fetch_array($result)){

 

    // grab video filename

 

    $filename=substr($row3['file_name'],19);

 

    $ffmpegPath = "/usr/local/bin/ffmpeg";

 

    $output_file = 'testimonials/video_snap/';

 

    $new_flv = 'testimonials/video/'.$filename;

 

    $fullloc = 'testimonials/video/'.$filename;

 

    $file_name_no_extension = substr($filename,0,-4);

 

    $debugmodex = 0;

 

 

 

    $thumb_position="00:00:02";

 

 

 

    //  Create thumnail image

 

    $output_file .= $file_name_no_extension . '.jpg';

 

 

 

    // ffmpeg command to generate thumbnail

 

    $ffmpeg_cmd2 = "$ffmpegPath -i $new_flv -ss $thumb_position -t 00:00:01 -s 90x68 -r 1 -f mjpeg $output_file";

 

    //execute and record output to variable

 

 

 

    @exec("$ffmpeg_cmd2 2>&1", $output);

 

 

 

    if (@file_exists($output_file)) {

 

      // thumb created successfully, update db

 

      $sql2 = "update testimonials set thumb_loc='$output_file' where id='$testimonial_id' limit 1";

 

      $result2 = mysql_query($sql2) or die(mysql_error());

 

 

 

      return true;

 

 

 

    }

 

 

 

    //debugging

 

    $debug_3 = $ffmpeg_cmd2 . "\n";//file line of debug

 

    foreach ($output as $outputline) {

 

      $debug_3 = $debug_3 . $outputline . "\n";

 

      if ($debugmodex == 1) {//no debug mode

 

        echo ("$outputline<br>");

 

      }

 

    }

 

    }

 

    return false;

 

  }else{

 

    return false;

 

  }

 

}

 

 

 

  function grabAllVids()

 

  {

 

  $sql = "SELECT *  FROM `testimonials` WHERE `is_approved` = 1 AND `is_banned` = '0' AND `is_deleted` = '0' AND `is_video` = 1 order by is_featured desc";

 

    $result = mysql_query($sql) or die(mysql_error());

 

    $num_rows = mysql_num_rows($result);

 

    if($num_rows <> 0)

 

    {

 

      while($row = mysql_fetch_array($result))

 

      {

 

        $sql2 = "SELECT * FROM `users` WHERE `id`='".$row['user_id']."'";

 

        $result2 = mysql_query($sql2) or die(mysql_error());

 

        $num_rows2 = mysql_num_rows($result2);

 

        if($num_rows2 <> 0)

 

        {

 

          while($row2 = mysql_fetch_array($result2))

 

          {

 

            $videos[$row['id']] = array($row['user_id'], $row2['first_name'], substr($row2['last_name'], 0, 1), $row2['address_city'], $row2['address_state'], $row['file_name'], $row['is_featured'], $row['thumb_loc'], $row['id'], $row['ordering']);

 

          }

 

        }

 

      }

 

    } else {

 

      $videos = "false";

 

    }

 

    return $videos;

 

  }

 

//VARS

 

 

 

 

 

// send to login if not super admin

 

permission_check(array("super admin"));

 

/* HANDLE INPUTS */

 

 

 

// handle toggle featured

 

if(isset($_POST['togglef'])){

 

  $setfeatured=0;

 

  $testimonial_id = '';

 

  $testimonial_id = mysql_real_escape_string($_POST['vid_id']);

 

  $isfeatured = mysql_real_escape_string($_POST['featured']);

 

  if($isfeatured=='0'){$setfeatured=1;}

 

 

 

  if(isset($testimonial_id)){

 

    // update is_featured column

 

    $sql = "update testimonials set is_featured = '$setfeatured' where id='$testimonial_id' limit 1";

 

    $query = @mysql_query($sql);

 

  }

 

}

 

 

 

// handle generate thumbnail

 

if(isset($_POST['createt'])){

 

  $testimonial_id = '';

 

  $testimonial_id = mysql_real_escape_string($_POST['vid_id']);

 

 

 

  $thumbresult = createThumb($testimonial_id);

 

  if(!$thumbresult){

 

    $report_error="Sorry, could not generate thumb.";

 

  }

 

}

 

// handle ordering save

 

if(isset($_POST['ordersubmit'])){

 

  $order = array();

 

  $order =$_POST['order'];

 

  print_r($order);

 

  exit;

 

 

 

  foreach ($order as $orderid => $ordering){

 

    $ordering = mysql_real_escape_string($ordering);

 

    if(intval($ordering < 10) && intval($ordering >=0)) {

 

    $sql = "update testimonials set `ordering` = '$ordering' where `id` = '$orderid' limit 1";

 

    $result = @mysql_query($sql);

 

    }

 

  }

 

}

 

// grab all videos

 

$vid_array = grabAllVids();

 

//print_r($featured_array);

 

 

 

if(@$vid_array != "false")

 

{

 

$body_main.="<div>$report_error</div><form action='managevids.php' method='post'><table width='720' style='padding-left:50px'>

 

<tr>

 

    <td width='30'>ID</td>

 

    <td width='100px'>Name</td>

 

    <td>Link to Vid</td>

 

    <td>Thumb</td>

 

    <td width='10%'>Order <input type='submit' name='ordersubmit' value='Save' /></td>

 

    <td>Featured?</td>

 

    <td>Set Status</td>

 

  </tr>";

 

foreach($vid_array as $featured_video_id => $featured_video_data)

 

  {

 

    $vie = $featured_video_data[5];

 

    $user_id = $featured_video_data[0];

 

    $username = $featured_video_data[1] . ' ' . $featured_video_data[2];

 

    $vid_id = $featured_video_data[8];

 

    $isfeatured = $featured_video_data[6];

 

    $isfeatnum = $isfeatured;

 

    $thumbnail = $featured_video_data[7];

 

    $ordering = $featured_video_data[9];

 

    if($thumbnail==''){

 

      $thumbnail = "<form action='managevids.php' method='post'><input type='hidden' name='vid_id' value='$vid_id'><input type='submit' value='Create Thumb' name='createt' id='createt'></form>";

 

    }else{

 

      $thumbnail = "<img src='$thumbnail' />";

 

    }

 

    if($isfeatured=='1'){

 

      $isfeatured='Yes';

 

      $orderrow = "<td><input type='text' name='order[$vid_id]'' size='3' value='$ordering'</td>";

 

    }else{$isfeatured='No';$orderrow='<td> </td>';}

 

$body_main.=<<<BODY

 

<!--// Start Inner Template Holder //-->

 

  <tr>

 

    <td width='30' style='border-bottom: 1px solid #eeeeee;'>$vid_id</td>

 

    <td width='100px' style='border-bottom: 1px solid #eeeeee;'>$username</td>

 

    <td style='border-bottom: 1px solid #eeeeee;'><a href='testimonial.php?tuid=$user_id'>View</a></td>

 

    <td style='border-bottom: 1px solid #eeeeee;'>$thumbnail</td>

 

    $orderrow

 

    <td width='30px' style='border-bottom: 1px solid #eeeeee;'>$isfeatured</td>

 

    <td style='border-bottom: 1px solid #eeeeee;'><form action='managevids.php' method='post'><input type='hidden' name='vid_id' value='$vid_id'><input type='hidden' name='featured' value='$isfeatnum'><input type='submit' value='Toggle Featured' name='togglef' id='togglef'></form></td>

 

  </tr>

 

<!--// End Inner Template Holder //-->

 

BODY;

 

}

 

$body_main.="</table></form>";

 

require_once("sharenow_template.php");

 

exit();

 

 

 

  }

 

?>

 

 

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/165362-ie-7-and-bug-with-post-array/
Share on other sites

Try to use code tags to surround your code!

You have an error here

$orderrow = "<td><input type='text' name='order[$vid_id]'' size='3' value='$ordering'</td>";

Your HTML element is incomplete and has an extra ' after the array.

It is much easier to spot if you use the following standard

<?php
$orderrow = "<td><input type='text' name='order[".$vid_id."]' size='3' value='".$ordering."' /></td>";
?>

Correct. I know I don't have to escape inner quotes. I am just trying all possiblities. It is still a problem. It only returns the first element in IE. I tried single and double quotes. It is just so weird. All looks fine...... I am not sure what else it could be. How IE handles associative arrays???

 

To give you an idea what the page looks like.

It is the input text boxes. I use Web toolbar in FF to get more info. But IE returns no errors. Are their anyother debugging tools? thanks

 

[attachment deleted by admin]

Wouldn't all browsers parse PHP the same way, if it is server-side, shouldn't that mean regardless of the browser the same output is shown?

For example when you say "How IE handles associative arrays" i'd have though that it's not IE that handles them but the server, althought i'm not 100% (hopefully someone can clarify yay or nay.

 

If this is the case it would mean it's a HTML problem, and all browsers have different ways of displaying HTML, for example IE doesn't like to follow standards (or struggles to).

 

 

Actually, this appears to be a bug in IE. Since it works in all other browsers. Seems naming a input text box with an array ( with the [ ] ) confuses IE. IE using ASP finds the [ ]  has another meaning and this is a bug in IE's code. Clearly the error from the print_r($order) exit; tells me exactly WHERE the error is, but not WHAT the error is. Thanks for all your input, but looks like it is a bug. Kip

Wouldn't all browsers parse PHP the same way, if it is server-side, shouldn't that mean regardless of the browser the same output is shown?

 

The server parses the php the same way, but sometimes browsers send the information to be parsed in different ways - particularly with invalid code in forms, for example nested forms which the php god of all might pfmbasiodsodiap mentioned above.

Thank you all. But it does appear to be a bug in IE.

error_reporting(E_ALL); is already enabled.

It was validated in the HTML validator under W3C.

I made the one correction that didn't make a difference. Apparently the browsers forgave that. But still removed the single quote.

 

I debugged to find out exactly where the array does not return the elements only the first element is returned.

I read the documentation before coming to this forum.

 

I said the same thing

"Wouldn't all browsers parse PHP the same way, if it is server-side, shouldn't that mean regardless of the browser the same output is shown?"

 

But FACTS remain, working in ALL other browsers, but NOT IE 8 or 7 - not sure about 6.

 

Unless someone has the correction or sees the problem, then you are just telling me what I already know or tried.

 

The file is here in full and was attached. print_r the array and it works in all browsers, print_r the array in IE and you get the first element.

 

There is no issue with the following in any version of IE

<input type='text' name='order[1]' size='3' value='123' />

 

I use this method very frequently. Your HTML has to be invalid no matter what W3C states. The browser does not have anything to do with php (php is server side). It is what you are sending to the php processor (POST data from HTML) that is invalid. Some browsers are more forgiving with invalid HTML like FF and may auto-correct it hence you have no issue with those browsers.

 

Like the PP states you need to post the HTML produced by your script.

Thank you. The code you site, would work, but my code .....($vid_id is an INT)

 

// your example code

<input type='text' name='order[1]' size='3' value='123' />

 

 

I am sure there is not issue with this above, however, using a variable is perhaps the problem. OR, it is not this line at all. I am only assuming it is this line since the array does not post. Or the print_r does not return the elements, only the first one.

 

The file is too long to enter in this box. I have attached it.

I am looking forward to your thoughts on this output.

 

Thanks Kip

// IE problem code

<input type='text' name='order[$vid_id]' size='3' value='$ordering' />

 

I think it is how IE handles the name. ALSO, I changed the POST to a GET and the same thing happened.

If you could help, it would be much appreciated. I have attached the View Source. BTW, this is what went through the validator and debugger as well as the original code.

 

 

 

[attachment deleted by admin]

This is invalid

<form method="post" action="abc.php">
<input type="text" name="order[]" value="1" />
<form method="post" action="abc.php">
<input type="hidden" name="gvjhv" value="mhbhb" />
</form>
<input type="text" name="order[]" value="2" />
</form>

 

I would expect this to only give me a value of 1 if I print the values of $_POST['order'] as the nested form is ending the main form. Some browsers obviously accept this but it is bad practice.

Also, I pasted the HTML of that page at the w3.org validator and it has over 400 markup errors (many are duplicates due to the repeated content.) Whatever method you used to validate it did not address the overall resulting page. Many of these markup errors are simply because there is no DOCTYPE (you do need one.)

 

And yes, the nested forms are some of the HTML validation errors. There are also a handful of php generated errors in the page output that need to be addressed.

Thank you so much. THe answer is. HTML 3.0 does not allow nested forms. Nested forms is the answer. Despite the 400 errors are not real errors. This was a page a previous developer was fired and now we are trying to fix. This was a stumper because despite is being sloppy, it worked in all other browsers. If I new this small but important piece of information, surely it would have been found sooner. Thanks again for your trouble shooting methods. Kip

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.