Plz Any one Help Me.
An Eroor occured when using for loop
the code is
<?php
include ("includes/connection.php");
include ("includes/functions.php");
if (isset($_REQUEST['submit']))
{
if (($_REQUEST['dealer'] != "") && ($_REQUEST['cur_date'] != "") && ($_REQUEST['disp_date'] !="") && ($_REQUEST['density'] != "") && ($_REQUEST['size'] != "") && ($_REQUEST['thick'] !="") && ($_REQUEST['no_of_bun'] != "") && ($_REQUEST['grade'] != "") && ($_REQUEST['color'] !=""))
{
$result = mysql_query("INSERT INTO ORDER_NO VALUES('','" . $_REQUEST["dealer"] . "','" . $_REQUEST["cur_date"] ."','" . $_REQUEST["disp_date"] . "','0');");
$or_id = mysql_insert_id();
if (is_array($_REQUEST['thick']))
{
for ($i = 0; $i < count($_REQUEST['thick']); $i++)
{
for ($j = 0; $j < $_REQUEST['no_of_bun']; $j++)
{
mysql_query("INSERT INTO ORDER_DETAIL VALUES('','" . $or_id . "','" . $_REQUEST["density"] ."','" . $_REQUEST["size"] . "','" . $_REQUEST["thick"] . "','" . $_REQUEST["no_of_bun"] ."','" . $_REQUEST["grade"] . "','" . $_REQUEST["color"] . "');");
}
}
popup('Database array updated', 'New_Order.php');
}
else
{
for ($k = 0; $k < $_REQUEST['no_of_bun']; $k++)
{
mysql_query("INSERT INTO ORDER_DETAIL VALUES('','" . $or_id . "','" . $_REQUEST["density"][k] ."','" . $_REQUEST["size"][k] . "','" . $_REQUEST["thick"][k] . "','" . $_REQUEST["no_of_bun"][k] ."','" . $_REQUEST["grade"][k] . "','" . $_REQUEST["color"][k] . "',);");
}
}
//popup('Database not updated', 'New_Order.php');
}
else
{
popup('Enter All Entries, Database Not Updated', 'New_Order.php');
}
}
?>
Use of undefined constant
Moderator: General Moderators
Re: Use of undefined constant
You already have this thread. Don't create another, especially if it's absolutely worthless.
Also, edit your post and put your code in [ code=php ][ /code ] tags. Remove the extra spaces.
Also, use English. I hate people who say "plz" and can't/won't spell simple words like "error" correctly. You'd be amazed what people think of you if you act like you have an education.
Everytime you use "i" or "k" in your code, without a $, PHP thinks it's a constant. It isn't.
Use a $ just like you did at the beginning of the loops.
Also, edit your post and put your code in [ code=php ][ /code ] tags. Remove the extra spaces.
Also, use English. I hate people who say "plz" and can't/won't spell simple words like "error" correctly. You'd be amazed what people think of you if you act like you have an education.
Code: Select all
$_REQUEST['no_of_bun'][i]Use a $ just like you did at the beginning of the loops.