473,545 Members | 2,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Weird argument passing problem

Hi all:

I have a really weird problem. I am developing a customer catalog
system for my company and as such have delved into sessions for
authentication and access levels. So far, I have managed to get a
working system just about finished.

I am building an interface for our customer service folks to use to
manage registered customers and am seeing some weird behavior.

Basically, the main "my" page calls a page - managecust.php. That page
lists a synopsis of the contents of the users DB and the last cell of
each row contains an 'edit' and 'delete' option.

The edit option is a hyperlink of the type custedit.php?id ='xx' where
the 'xx' is the id returned during the initial search of the DB (using
a select * from db).

Theoretically, when the user clicks the edit link beside the
appropriate record, the custedit.php page is called with the id # of
the record being passed.

The weird part is that even though the URL passed is correct, the page
"remembers" which ever record was chosen FIRST.

managecust.php code:
---------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<head>
<title>Internat ional Enterprises, Inc. Depot Level F16 Avionics
Repair</title>
</head>

<body>

<?
include('css/header.php');
include('css/functions.php') ;
buildhead("Cust omer Data Management");
?>

<BR />
<div align="center">

<H3 class=bordered> Customer Data Management</H3>
<BR />

<TABLE CLASS=form BORDER=1 CELLSPACING=2 CELLPADDING=2>
<TR>
<TD>First Name</TD>
<TD>Last Name</TD>
<TD>Company Name</TD>
<TD>Login ID</TD>
<TD>Access Level</TD>
<TD>Options</TD>
</TR>
<?
// Setup pagination so we can browse the data set
if (isset($_GET['pageno'])) {
$pageno = $_GET['pageno'];
} else {
$pageno = 1;
}

// Count the rows in the DB
connectDB("xxxx xx");
$query = "SELECT count(*) FROM xxxxxxx";
$result = mysql_query($qu ery) or trigger_error(" SQL",E_USER_ERR OR);
$query_data = mysql_fetch_row ($result);
$numrows = $query_data[0];

// Calculate the number for $lastpage
$rows_per_page = 15; // We only want 15 rows per page. Adjust to fit
tastes.
$lastpage = ceil($numrows/$rows_per_page) ;

// Ensure that $pageno is within range
$pageno = (int)$pageno;
if ($pageno < 1) {
$pageno = 1;
} elseif ($pageno > $lastpage) {
$pageno = $lastpage;
} else {
$pageno = $pageno;
}

// Construct the LIMIT clause we will use
$limit = 'LIMIT '.($pageno - 1) * $rows_per_page. ','.$rows_per_p age;

// Issue the actual query for data from the DB and process the results
$sql="SELECT * from reginfo ORDER BY lname,fname $limit";
// echo $sql."<BR />";
$result = mysql_query($sq l) or die("Error reading from database
reginfo: ".mysql_error() );

while($myrow=my sql_fetch_array ($result)) {
echo "<TR>";
echo "<TD CLASS=data>".$m yrow['fname']."</TD>";
echo "<TD CLASS=data>".$m yrow['lname']."</TD>";
echo "<TD CLASS=data>".$m yrow['coname']."</TD>";
echo "<TD CLASS=data>".$m yrow['login']."</TD>";
echo "<TD CLASS=data>".$m yrow['level']."</TD>";
echo "<TD CLASS=data>
<A HREF=custedit.p hp?id=".$myrow['id'].">Edit</A> |
<A HREF=delcust.ph p?id=".$myrow['id'].">Delete</A></TD></TR>";
}
?>
</TABLE>
<BR />

<?
pagethru($pagen o,$lastpage)?>
</div>
<br />

<? include('css/footer.php'); ?>
</div>
</body>

custedit.php
--------------------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<head>
<title>Internat ional Enterprises, Inc. Depot Level F16 Avionics
Repair</title>

<meta name="Copyright " content="Copyri ght (c) International
Enterprises, Inc. 2004" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

<body>

<?
include('css/header.php');
include('css/functions.php') ;
buildhead("Edit Customer Information");
?>
<BR />

<?

if ($submit) {
// Connect to the DB and update the record
connectDB("xxxx xx");
$sql = "UPDATE xxxxxx SET
fname='$fname', lname='$lname', coname='$coname ',add1='$add1', add2='$add2',
city='$city',st ate='$state',zi p='$zip',countr y='$country',ph one='$phone',lo gin='$login',
email='$email', level='$level' WHERE id=$id";

$result = mysql_query($sq l) or die("Error updating record:
".mysql_error() );

if (isset ($_POST['sendemail'])) {
// send a response to the submitter.
$to=$email;
// email message and header stuff here
}

echo '<meta http-equiv="refresh" content="0; URL=managecust. php">"';

} else {
// Connect to the DB and retrieve the record
connectDB("cata log");
$sql = "SELECT * FROM reginfo WHERE id='$id'";
$result = mysql_query($sq l) or die("Error retrieving record:
".mysql_error() );

while ($myrow=mysql_f etch_array($res ult)) {
?>

<DIV ALIGN="CENTER">
<H3 CLASS=bordered> Edit Customer Information</H3>
<BR />

<FORM METHOD=post ACTION='custedi t.php'>
<TABLE CLASS=form BORDER="0">
<TR>
<TD ALIGN=center COLSPAN=3>Pleas e edit any items and submit to
update record</TD>
</TR>
<TR><TD></TD></TR>
<TR>
<TD ALIGN=right>Fir st Name</TD>
<TD><INPUT TYPE="text" NAME=fname SIZE=50 VALUE="<?= $myrow['fname']
?>"></TD>
</TR>
<TR>
<TD ALIGN=right>Las t Name</TD>
<TD><INPUT TYPE="text" NAME=lname SIZE=50 VALUE="<?= $myrow['lname']
?>"></TD>
</TR>
<TR>
<TD ALIGN=right>Com pany Name</TD>
<TD><INPUT TYPE="text" NAME=coname SIZE=50 VALUE="<?=
$myrow['coname'] ?>"></TD>
</TR>
<TR>
<TD ALIGN=right>Add ress</TD>
<TD><INPUT TYPE="text" NAME=add1 SIZE=50 VALUE="<?= $myrow['add1']
?>"></TD>
</TR>
<TR>
<TD ALIGN=right>Add ress</TD>
<TD><INPUT TYPE="text" NAME=add2 SIZE=50 VALUE="<?= $myrow['add2']
?>"></TD>
</TR>
<TR>
<TD ALIGN=right>Cit y</TD>
<TD><INPUT TYPE="text" NAME=city SIZE=50 VALUE="<?= $myrow['city']
?>"></TD>
</TR>
<TR>
<TD ALIGN=right>Sta te</TD>
<TD><INPUT TYPE="text" NAME=state SIZE=50 VALUE="<?= $myrow['state']
?>"></TD>
</TR>
<TR>
<TD ALIGN=right>Zip/Postal Code</TD>
<TD><INPUT TYPE="text" NAME=zip SIZE=50 VALUE="<?= $myrow['zip']
?>"></TD>
</TR>
<TR>
<TD ALIGN=right>Cou ntry</TD>
<TD><INPUT TYPE="text" NAME=country SIZE=50 VALUE="<?=
$myrow['country'] ?>"></TD>
</TR>
<TR>
<TD ALIGN=right>Pho ne</TD>
<TD><INPUT TYPE="text" NAME=phone SIZE=50 VALUE="<?= $myrow['phone']
?>"></TD>
</TR>
<TR>
<TD ALIGN=right>Ema il</TD>
<TD><INPUT TYPE="text" NAME=email SIZE=50 VALUE="<?= $myrow['email']
?>"></TD>
</TR>
<TR>
<TD ALIGN=right>Log in</TD>
<TD><INPUT TYPE="text" NAME=login SIZE=50 VALUE="<?= $myrow['login']
?>"></TD>
</TR>
<TR>
<TD ALIGN=right>Acc ess Level</TD>
<TD>
<SELECT NAME="level">
<OPTION VALUE=99>No Pricing</OPTION>
<OPTION VALUE=1>Base Price</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD>Send Credentials via Email</TD>
<TD><INPUT TYPE="checkbox" VALUE="sendemai l" NAME="sendemail "></TD>
</TR>
</TABLE>
<?
}
?>

<BR>
<DIV ALIGN="CENTER">
<INPUT TYPE="submit" NAME="submit" VALUE=Update>
<INPUT TYPE="reset" NAME="reset" VALUE=Reset />
</DIV>
</FORM>
<?
}
?>

<br />

<? include('css/footer.php'); ?>
</div>
</body>
Can anyone tell me why this is happening? If I paste the URL directly,
all works well.

TIA

rk

Jul 17 '05 #1
3 2070
Not sure if this will help, but it is a good idea to combine your GET
and POST vars into an array.

$attributes = array_merge($HT TP_GET_VARS, $HTTP_POST_VARS )
This makes longer scripts easier to understand.

Jul 17 '05 #2
Not sure if this will help, but it is a good idea to combine your GET
and POST vars into an array.

$attributes = array_merge($HT TP_GET_VARS, $HTTP_POST_VARS )
This makes longer scripts easier to understand.


or use $_REQUEST, which is a combination of get/post/cookies.

longer scripts rather need to use get/post in one place only,
and use functions or classes for futher operation on acquired data.
--
* html {redirect-to: url(http://browsehappy.pl) ;}
Jul 17 '05 #3
Actually, using $_GET['id'] at the start of the main ELSE structure on
the custedit.php page solved the problem. Thanks to everyone for the
input.

rk

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1769
by: Frank Bechmann | last post by:
Eventually most of you will not learn much from this because it's just another event in the 'default argument value gotcha' series, but because it cost me some hours yesterday to spot this 'error' in a famous python tool I thought it might still help other people to save some time. I tried to use some method which was documented to write to...
8
3949
by: Alex Vinokur | last post by:
Various forms of argument passing ================================= C/C++ Performance Tests ======================= Using C/C++ Program Perfometer http://sourceforge.net/projects/cpp-perfometer http://alexvn.freeservers.com/s1/perfometer.html
11
1581
by: Anon Email | last post by:
Hey people, This looks really weird. I can't make sense of it. Is this a mistake? Can anyone help? IStack const & GetStack () const; Cheers,
17
3576
by: Charles Sullivan | last post by:
The library function 'qsort' is declared thus: void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); If in my code I write: int cmp_fcn(...); int (*fcmp)() = &cmp_fcn; qsort(..., fcmp); then everything works. But if instead I code qsort as:
2
1739
by: Alexander Fedin | last post by:
Guys, I 've met some strange behaviour of the C# compiler. To reproduce it please try to compile the code below and you 'll be really amazed. The problem is that you can not use an interface pointer variable as a ref-to-object parameter. interface IMy { void f(); }
3
3392
by: matko | last post by:
This is a long one, so I'll summarize: 1. What are your opinions on raising an exception within the constructor of a (custom) exception? 2. How do -you- validate arguments in your own exception constructors? I've noticed that, f.ex., ArgumentException accepts null arguments without raising ArgumentNullException. Obviously, if nothing is...
8
2279
by: A. Anderson | last post by:
Howdy everyone, I'm experiencing a problem with a program that I'm developing. Take a look at this stack report from GDB - #0 0xb7d782a3 in strlen () from /lib/tls/i686/cmov/libc.so.6 #1 0xb7d4c2f7 in vfprintf () from /lib/tls/i686/cmov/libc.so.6 #2 0xb7d6441b in vsprintf () from /lib/tls/i686/cmov/libc.so.6 #3 0x08049ba0 in...
16
1751
by: Bill Nguyen | last post by:
I'm running into a very weird problem regarding subtraction. Subtraction behaves as if it's an addition in the below sub txtJacoCost.Text = Format(mRackc - (mDisc + mJaEc), "0.#####0") txtWfCost.Text = Format(mRackc - mDisc + mWfEC, "0.#####0")
6
2810
by: zhangsonglovexiaoniuniu | last post by:
Dear all, I need you help. here the program: char a = 0x91; printf("%x",a);
0
7487
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7420
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7680
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7778
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5349
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4966
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1908
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1033
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.