PHP Notice: Undefined offset ???

Discussion in 'PHP' started by koolsamule, Jan 12, 2010.

  1. #1
    Hi Chaps,

    I'm having some trouble with a PHP Form page and an Update Script page.

    I've tested this on my Apache server and it works fine, but fails on my 'Live' IIS server:
    Form Code:
    <input type='text' name='jobpriority[]' value="<?php echo $row_rsWorkload_All['jobpriority'];?>"/>
    <?php echo $row['jobcount']; ?>
    <?php echo $row_rsWorkload_All['jobpriority'];?>
    <?php
    	$table_name = $row_rsWorkload_All['fromtable'];
            $item_id = $row_rsWorkload_All['jobid']; 
    ?>
    
    <input type="hidden" name="setpriority[]" value="<?php echo $table_name; ?>:<?php echo $item_id; ?>" />
    PHP:
    The 'hidden' input did look like this:
    <input type="hidden" name="setpriority[]" value="<?php echo $table_name; ?>:<?php echo $item_id; ?>:<?php $_POST ['jobpriority']; ?>" />
    PHP:
    But I had to remove the
    :<?php $_POST ['jobpriority']
    Code (markup):
    bit to get the page to open on the IIS server.
    Since removing the code, the page opens but when I 'click send' to pass the data to the script page, I get this error:
    Script.PHP:
    $allowed_tables = Array('tbl_table1','tbl_table2','tbl_table3'); // to prevent SQL injection
     $i = 1;
    foreach($_POST['setpriority'] as $var) {
        $arr = explode(':', $var);
        if(in_array($arr[0], $allowed_tables)) {
            $table = $arr[0];
            $rowid = $arr[1];
            $priority = $_POST['jobpriority'][$i];
    		$i++;
            if(is_numeric($rowid)) {
                // run your SQL query here to update $table where row matches $rowid
                $query = sprintf("
    			UPDATE $table 
    			SET jobpriority='$priority' 
    			WHERE jobid=$rowid");
                $result = mysql_query($query, $conndb2) or die(mysql_error());
    			$mess = $ref = $_SERVER['HTTP_REFERER']; header( 'refresh: 0; url='.$ref);
            }
        else {
      $mess = "<p>There was a problem</p>";
    }
    	}
    }
    Code (markup):
    I'm a bit stuck as I have around 10 pages that use the same sort of functionality, so if anyone can help with this, I'd be most grateful!
     
    koolsamule, Jan 12, 2010 IP
  2. koolsamule

    koolsamule Peon

    Messages:
    101
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0