Jump to content

Undefined offset 2


mynameisjayson

Recommended Posts

Hi

 

 

I am having undefined offset:2 and any body can give me an idea, why i get this error message.

for($i = 0; $i< count($from_branch) || $i< count($to_branch) || $i< count($quantity) || $i< count($prio_color); $i++)	
									
     {
	$query = mysql_query("INSERT INTO pull_out(`description`,`barcode`,`from`,`to`,quantity,prio_color,date_created,remarks,userid) VALUES('$desc','$barc','$from_branch[$i]','$to_branch[$i]','$quantity[$i]','$prio_color[$i]','$datec','$remar','$userid')");
							
     }

and i use checkbox under prio_color and i think this is the cause, 

Link to comment
Share on other sites

but i have a correct index from each you suggest.  

<script type="text/javascript">
	var rowNum = 0;
	function addRow(frm) 
			{
				rowNum ++;
				var row = '<p id="rowNum'+rowNum+'"><input type="text" class="form-control" name = "from_branch[]"style = "width:250px;" placeholder="From" value="" required> <input type="text" id="from_2" class="form-control" placeholder="To" style = "width:250px;margin-top:-34px; margin-left:280px;" name = "to_branch[]" value="" required> <input type="text" class="form-control" placeholder="#"style = "width:80px;margin-top:-34px; margin-left:560px;" name = "quantity[]" value="" required> <input type = "checkbox" name = "prio_color[]" value = "#d6f4ca#fd3236" style = "position:absolute;width:80px; margin-top:-23px; margin-left:620px;">  <button type="button" value="Remove" class="btn btn-default" style = "width:40px; margin-top:-57px; margin-left:680px;"onclick="removeRow('+rowNum+');"><span class = "glyphicon glyphicon-minus"></button></p>';
				jQuery('#itemRows').append(row);
				
			}
			function removeRow(rnum) {
			jQuery('#rowNum'+rnum).remove();
			}
		</script>
Link to comment
Share on other sites

If prio_color isnt inserting then it means it doesn't have that index you are establishing with your loop.

so you have to either get the array to have that index or change the way you are inserting it.

 

Hard to come up with a solution not knowing what you are trying to accomplish or how you are getting to this point.

Are you just simply trying to add the form results to the DB or something different.

Link to comment
Share on other sites

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.