Jump to content

Undefined index!! Need help


dshouse069

Recommended Posts

I am very new to PHP and one of our current php pages has broken. The creator of these pages left and i got stuck maintaining these pages. It worked for almost a year and then one day we started getting this error. Here is the error that it is gets:

Undefined index: Submit in C:\Program Files\Apache Group\Apache2\htdocs\motorcircle\small_part_entry.php on line 41




Here is the code for that particular line and below:

if ( $_GET['Submit'] == 'Submit'){
print "<P>";
$part_info = array();
$part_count = 0;
while(list($key, $val) = each ($_GET)){
$temp = array($key=>$val);
// print "$key=>$val<br>";
if ($key != "Submit"){$part_info = array_merge($part_info, $temp);}
}


Please HELP ME!!

Link to comment
https://forums.phpfreaks.com/topic/10444-undefined-index-need-help/
Share on other sites

[!--quoteo(post=377064:date=May 25 2006, 11:30 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ May 25 2006, 11:30 AM) [snapback]377064[/snapback][/div][div class=\'quotemain\'][!--quotec--]
When doing comparison checks with superglobal arrays always use isset like so:
[code] if ( isset( $_GET['Submit'] ) && $_GET['Submit'] == 'Submit'){[/code]

That then stops the notice error apearing if Submit is not set.
[/quote]



I tried that coding and nothing happens when i hit the submit button. It will not allow the database to be updated or anything... Any other ideas?? Thanks in advance
[!--quoteo(post=377098:date=May 25 2006, 01:39 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ May 25 2006, 01:39 PM) [snapback]377098[/snapback][/div][div class=\'quotemain\'][!--quotec--]
What method are you using in your form? GET or POST, if it is POST, you should be using the $_POST array, not the $_GET array.

Ken
[/quote]


Using Get.... Here is entire code

if ( $_GET['Submit'] == 'Submit'){
print "<P>";
$part_info = array();
$part_count = 0;
while(list($key, $val) = each ($_GET)){
$temp = array($key=>$val);
// print "$key=>$val<br>";
if ($key != "Submit"){$part_info = array_merge($part_info, $temp);}
}
while(list($key, $val) = each ($part_info)){
if ($val == "true"){
$count_index = $key . "_count";
$part_count = $part_info[$count_index];
if (!$part_count){print "You have not specified a quantity for $key. Please correct.";exit;}
print "Updating $key with quantity $part_count...<br>";
$query = "SELECT * FROM `$key` ORDER BY last_update DESC LIMIT 1";
$data_result = dbquery($query, $connection);
$data_row = mysql_fetch_array($data_result, MYSQL_ASSOC);
$part_count = $data_row['inventory'] + $part_count;
$query = "INSERT INTO `$key` (inventory, order_number, quantity, last_update) VALUES ($part_count, -1, 0, NOW())";
$result = dbquery($query, $connection);
print "Quantity of $key - $data_row[model] has been changed from $data_row[inventory] to $part_count.<br>";
}
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.