[PHP] POST a variable

2007-03-23 Thread Dan Shirah

Okay, I feel like the correct answer to this is about 2mm back in my grey
matter.

1. I have a query that pulls the last row number when a newly inserted
record is added:

$maximum=SELECT MAX(payment_id) FROM payment_request;
 $max_result=mssql_query($maximum);
 while($max=mssql_fetch_row($max_result)){
 }
 $max_id = $max[0];

2. I have multiple selections for the user to pick, but regardless of what
they choose I want the $max_id variable to be passed to the next page.

3.  Would I go about this by assigning $max_id to a hidden field like below?

input type=hidden value=?php echo $max_id; ? size=5
maxlength=10 name=max_id /

4.  And then to retrieve this value on my next page just get it out of
$_POST['max_id']  ??

Does that all sound correct?


Re: [PHP] POST a variable

2007-03-23 Thread Németh Zoltán
2007. 03. 23, péntek keltezéssel 10.45-kor Dan Shirah ezt írta:
 Okay, I feel like the correct answer to this is about 2mm back in my grey
 matter.
 
 1. I have a query that pulls the last row number when a newly inserted
 record is added:
 
 $maximum=SELECT MAX(payment_id) FROM payment_request;
   $max_result=mssql_query($maximum);
   while($max=mssql_fetch_row($max_result)){
   }
   $max_id = $max[0];
 
 2. I have multiple selections for the user to pick, but regardless of what
 they choose I want the $max_id variable to be passed to the next page.
 
 3.  Would I go about this by assigning $max_id to a hidden field like below?
 
 input type=hidden value=?php echo $max_id; ? size=5
 maxlength=10 name=max_id /
 
 4.  And then to retrieve this value on my next page just get it out of
 $_POST['max_id']  ??
 
 Does that all sound correct?

basically yes
but if you want the id of the row you just inserted, using
mysql_insert_id() is better because if another insert is happening at
the same time, select max() may give you incorrect result

greets
Zoltán Németh

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] POST a variable

2007-03-23 Thread Dan Shirah

The reason I have to use it as I posted is because I am using Microsoft SQL
server instead of MySQL.  And I haven't found a php function for MSSQL that
works the same as mysql_insert_id()

So, to come out with a comparable function with pretty reliable results, I
follow this process:

1. User enters data into form
2. User submits form
3. Save page inserts info into the database
4. Directly after the insert statement is my SELECT MAX query
5. I assign the retrieved value to a hidden field
6. I pass this value to the next form

I figure the odds of another record being inserted inbetween the time it
takes to go from step 3 to step 4 are very, very minimal.  We're talking
about MAYBE a 2-3 millisecond gap?


On 3/23/07, Németh Zoltán [EMAIL PROTECTED] wrote:


2007. 03. 23, péntek keltezéssel 10.45-kor Dan Shirah ezt írta:
 Okay, I feel like the correct answer to this is about 2mm back in my
grey
 matter.

 1. I have a query that pulls the last row number when a newly inserted
 record is added:

 $maximum=SELECT MAX(payment_id) FROM payment_request;
   $max_result=mssql_query($maximum);
   while($max=mssql_fetch_row($max_result)){
   }
   $max_id = $max[0];

 2. I have multiple selections for the user to pick, but regardless of
what
 they choose I want the $max_id variable to be passed to the next page.

 3.  Would I go about this by assigning $max_id to a hidden field like
below?

 input type=hidden value=?php echo $max_id; ? size=5
 maxlength=10 name=max_id /

 4.  And then to retrieve this value on my next page just get it out of
 $_POST['max_id']  ??

 Does that all sound correct?

basically yes
but if you want the id of the row you just inserted, using
mysql_insert_id() is better because if another insert is happening at
the same time, select max() may give you incorrect result

greets
Zoltán Németh




RE: [PHP] POST a variable

2007-03-23 Thread Edward Kay
 -Original Message-
 From: Németh Zoltán [mailto:[EMAIL PROTECTED]

 2007. 03. 23, péntek keltezéssel 10.45-kor Dan Shirah ezt írta:
  Okay, I feel like the correct answer to this is about 2mm back 
 in my grey
  matter.
  
  1. I have a query that pulls the last row number when a newly inserted
  record is added:
  
  $maximum=SELECT MAX(payment_id) FROM payment_request;
$max_result=mssql_query($maximum);
while($max=mssql_fetch_row($max_result)){
}
$max_id = $max[0];
  
  2. I have multiple selections for the user to pick, but 
 regardless of what
  they choose I want the $max_id variable to be passed to the next page.
  
  3.  Would I go about this by assigning $max_id to a hidden 
 field like below?
  
  input type=hidden value=?php echo $max_id; ? size=5
  maxlength=10 name=max_id /
  
  4.  And then to retrieve this value on my next page just get it out of
  $_POST['max_id']  ??
  
  Does that all sound correct?
 
 basically yes

Personally, I'd put it in a session variable. This reduces the amount of data 
sent to/from the client and also stops anyone altering the value themselves. 

 but if you want the id of the row you just inserted, using
 mysql_insert_id() is better because if another insert is happening at
 the same time, select max() may give you incorrect result

This would be true if he was using MySQL. The code given uses MSSQL and there 
is no mssql_insert_id function (in my PHP manual).

Edward 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] POST a variable

2007-03-23 Thread Németh Zoltán
2007. 03. 23, péntek keltezéssel 11.07-kor Dan Shirah ezt írta:
 The reason I have to use it as I posted is because I am using
 Microsoft SQL server instead of MySQL.  And I haven't found a php
 function for MSSQL that works the same as mysql_insert_id()

you wrote something earlier as far as I can remember about a MSSQL
function scope_identity() which returns the last inserted id

why not use that?

greets
Zoltán Németh

  
 So, to come out with a comparable function with pretty reliable
 results, I follow this process:
  
 1. User enters data into form
 2. User submits form
 3. Save page inserts info into the database
 4. Directly after the insert statement is my SELECT MAX query
 5. I assign the retrieved value to a hidden field
 6. I pass this value to the next form
  
 I figure the odds of another record being inserted inbetween the time
 it takes to go from step 3 to step 4 are very, very minimal.  We're
 talking about MAYBE a 2-3 millisecond gap?
 
  
 On 3/23/07, Németh Zoltán [EMAIL PROTECTED] wrote: 
 2007. 03. 23, péntek keltezéssel 10.45-kor Dan Shirah ezt
 írta:
  Okay, I feel like the correct answer to this is about 2mm
 back in my grey 
  matter.
 
  1. I have a query that pulls the last row number when a
 newly inserted
  record is added:
 
  $maximum=SELECT MAX(payment_id) FROM payment_request;
$max_result=mssql_query($maximum); 
while($max=mssql_fetch_row($max_result)){
}
$max_id = $max[0];
 
  2. I have multiple selections for the user to pick, but
 regardless of what
  they choose I want the $max_id variable to be passed to the
 next page. 
 
  3.  Would I go about this by assigning $max_id to a hidden
 field like below?
 
  input type=hidden value=?php echo $max_id; ?
 size=5 
  maxlength=10 name=max_id /
 
  4.  And then to retrieve this value on my next page just get
 it out of
  $_POST['max_id']  ??
 
  Does that all sound correct? 
 
 basically yes
 but if you want the id of the row you just inserted, using
 mysql_insert_id() is better because if another insert is
 happening at
 the same time, select max() may give you incorrect result
 
 greets
 Zoltán Németh
 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] POST a variable

2007-03-23 Thread Satyam
Do a 'select @@identity', it will give you the last record id.  The gap in 
between steps 3 and 4, brief as it may seem, is enough to get you in 
trouble.


Satyam



- Original Message - 
From: Dan Shirah [EMAIL PROTECTED]

To: Németh Zoltán [EMAIL PROTECTED]
Cc: php-general php-general@lists.php.net
Sent: Friday, March 23, 2007 4:07 PM
Subject: Re: [PHP] POST a variable


The reason I have to use it as I posted is because I am using Microsoft SQL
server instead of MySQL.  And I haven't found a php function for MSSQL that
works the same as mysql_insert_id()

So, to come out with a comparable function with pretty reliable results, I
follow this process:

1. User enters data into form
2. User submits form
3. Save page inserts info into the database
4. Directly after the insert statement is my SELECT MAX query
5. I assign the retrieved value to a hidden field
6. I pass this value to the next form

I figure the odds of another record being inserted inbetween the time it
takes to go from step 3 to step 4 are very, very minimal.  We're talking
about MAYBE a 2-3 millisecond gap?


On 3/23/07, Németh Zoltán [EMAIL PROTECTED] wrote:


2007. 03. 23, péntek keltezéssel 10.45-kor Dan Shirah ezt írta:
 Okay, I feel like the correct answer to this is about 2mm back in my
grey
 matter.

 1. I have a query that pulls the last row number when a newly inserted
 record is added:

 $maximum=SELECT MAX(payment_id) FROM payment_request;
   $max_result=mssql_query($maximum);
   while($max=mssql_fetch_row($max_result)){
   }
   $max_id = $max[0];

 2. I have multiple selections for the user to pick, but regardless of
what
 they choose I want the $max_id variable to be passed to the next page.

 3.  Would I go about this by assigning $max_id to a hidden field like
below?

 input type=hidden value=?php echo $max_id; ? size=5
 maxlength=10 name=max_id /

 4.  And then to retrieve this value on my next page just get it out of
 $_POST['max_id']  ??

 Does that all sound correct?

basically yes
but if you want the id of the row you just inserted, using
mysql_insert_id() is better because if another insert is happening at
the same time, select max() may give you incorrect result

greets
Zoltán Németh









No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.17/730 - Release Date: 22/03/2007 
7:44


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] POST a variable

2007-03-23 Thread Dan Shirah

Sorry, I was more tailoring my question to the syntax of my query.  It
wasn't displaying anything for my echo.

I've changed it to this now:

$get_max = SELECT scope_identity();
 $max_result = mssql_query($get_max) or die(mssql_error());
 $max_id = mssql_fetch_row($max_result);
 echo $max_id;

But all my echo returns is array instead of the number.

Below are brief explanations of the different _identity uses you have.

SELECT *@@IDENTITY*
Returns the last IDENTITY value produced on a connection, regardless of the
table that produced the value, and regardless of the scope of the statement
that produced the value.

SELECT *IDENT_CURRENT(*'*tablename*'*)*
This new function returns the last IDENTITY value produced in a table,
regardless of the connection that created the value, and regardless of the
scope of the statement that produced the value.

SELECT *SCOPE_IDENTITY()*
This new function returns the last IDENTITY value produced on a connection
and by a statement in the same scope, regardless of the table that produced
the value.


On 3/23/07, Satyam [EMAIL PROTECTED] wrote:


 I don't really know about the scope_identity() function, neither much
about @@identity.  I know that the names preceded by @@ are MSSQL internal
variables and I think that is the one you are looking for, I just checked in
the on-line MS documentation, but have no SQL server active at this moment,
nor have I dealt with one for the last few years, though I did use
auto-increment fields and I certainly was able to retrieve the last id,
somehow.  I might be wrong and there might be another function or variable
that gives you the value, but it looks to me @@identity is the one you are
looking for.

There is no need in your code to do any while, if the SQL statement
doesn't fail and triggers the die(), you can rest assured you'll get a
record with a single field, even if it only contains a null, that's the way
with variables, you can't fail on them, though they might return null.

Satyam


- Original Message -
*From:* Dan Shirah [EMAIL PROTECTED]
 *To:* Satyam [EMAIL PROTECTED]
*Sent:* Friday, March 23, 2007 7:14 PM
*Subject:* Re: [PHP] POST a variable


Satyam, I'm trying to retrieve the id using the identity method, but I do
not get anything returned.  Do you see anything wrong with this code?

$get_max = SELECT scope_identity();
  $max_result = mssql_query($get_max) or die(mssql_error());
  while($max=mssql_fetch_row($max_result)){
}
$max_id = $max[0];
  echo $max_id;


On 3/23/07, Satyam [EMAIL PROTECTED] wrote:

 Do a 'select @@identity', it will give you the last record id.  The gap
 in
 between steps 3 and 4, brief as it may seem, is enough to get you in
 trouble.

 Satyam



 - Original Message -
 From: Dan Shirah [EMAIL PROTECTED]
 To: Németh Zoltán  [EMAIL PROTECTED]
 Cc: php-general php-general@lists.php.net
 Sent: Friday, March 23, 2007 4:07 PM
 Subject: Re: [PHP] POST a variable


 The reason I have to use it as I posted is because I am using Microsoft
 SQL
 server instead of MySQL.  And I haven't found a php function for MSSQL
 that
 works the same as mysql_insert_id()

 So, to come out with a comparable function with pretty reliable results,
 I
 follow this process:

 1. User enters data into form
 2. User submits form
 3. Save page inserts info into the database
 4. Directly after the insert statement is my SELECT MAX query
 5. I assign the retrieved value to a hidden field
 6. I pass this value to the next form

 I figure the odds of another record being inserted inbetween the time it
 takes to go from step 3 to step 4 are very, very minimal.  We're talking
 about MAYBE a 2-3 millisecond gap?


 On 3/23/07, Németh Zoltán [EMAIL PROTECTED] wrote:
 
  2007. 03. 23, péntek keltezéssel 10.45-kor Dan Shirah ezt írta:
   Okay, I feel like the correct answer to this is about 2mm back in my

  grey
   matter.
  
   1. I have a query that pulls the last row number when a newly
 inserted
   record is added:
  
   $maximum=SELECT MAX(payment_id) FROM payment_request;
 $max_result=mssql_query($maximum);
 while($max=mssql_fetch_row($max_result)){
 }
 $max_id = $max[0];
  
   2. I have multiple selections for the user to pick, but regardless
 of
  what
   they choose I want the $max_id variable to be passed to the next
 page.
  
   3.  Would I go about this by assigning $max_id to a hidden field
 like
  below?
  
   input type=hidden value=?php echo $max_id; ? size=5
   maxlength=10 name=max_id /
  
   4.  And then to retrieve this value on my next page just get it out
 of
   $_POST['max_id']  ??
  
   Does that all sound correct?
 
  basically yes
  but if you want the id of the row you just inserted, using
  mysql_insert_id() is better because if another insert is happening at
  the same time, select max() may give you incorrect result
 
  greets
  Zoltán Németh
 
 



 




 No virus found in this incoming message

Re: [PHP] POST a variable

2007-03-23 Thread Satyam
It seems to me @@identity should sufice, and it certainly does not need to 
be any 'new' function, since it had been there for quite a while.  My 
feeling is that those added functions might be used for elaborate stored 
procedures, where you might be dealing with multiple tables or some fancy 
administrative uses.  You certainly DON'T want any function that gives you 
the last identity of some other connection!


$get_max = SELECT @@identity;
 $max_result = mssql_query($get_max) or die(mssql_error());
 $max_id = mssql_fetch_row($max_result);
 echo $max_id[0];

Though the fetch will return only one record with only one field, it will 
still return that as an array, even if it only contains one element, so you 
still need to add the [0].  Unfortunately, PHP doesn't allow the brackets to 
a function that returns an array.


You might use mssql_result instead:

$get_max = SELECT @@identity;
 $max_result = mssql_query($get_max) or die(mssql_error());
 $max_id = mssql_result($max_result,0,0);
 echo $max_id;


Satyam

- Original Message - 
From: Dan Shirah [EMAIL PROTECTED]

To: Satyam [EMAIL PROTECTED]
Cc: php-general php-general@lists.php.net
Sent: Friday, March 23, 2007 7:48 PM
Subject: Re: [PHP] POST a variable


Sorry, I was more tailoring my question to the syntax of my query.  It
wasn't displaying anything for my echo.

I've changed it to this now:

$get_max = SELECT scope_identity();
 $max_result = mssql_query($get_max) or die(mssql_error());
 $max_id = mssql_fetch_row($max_result);
 echo $max_id;

But all my echo returns is array instead of the number.

Below are brief explanations of the different _identity uses you have.

SELECT *@@IDENTITY*
Returns the last IDENTITY value produced on a connection, regardless of the
table that produced the value, and regardless of the scope of the statement
that produced the value.

SELECT *IDENT_CURRENT(*'*tablename*'*)*
This new function returns the last IDENTITY value produced in a table,
regardless of the connection that created the value, and regardless of the
scope of the statement that produced the value.

SELECT *SCOPE_IDENTITY()*
This new function returns the last IDENTITY value produced on a connection
and by a statement in the same scope, regardless of the table that produced
the value.


On 3/23/07, Satyam [EMAIL PROTECTED] wrote:


 I don't really know about the scope_identity() function, neither much
about @@identity.  I know that the names preceded by @@ are MSSQL internal
variables and I think that is the one you are looking for, I just checked 
in
the on-line MS documentation, but have no SQL server active at this 
moment,

nor have I dealt with one for the last few years, though I did use
auto-increment fields and I certainly was able to retrieve the last id,
somehow.  I might be wrong and there might be another function or variable
that gives you the value, but it looks to me @@identity is the one you are
looking for.

There is no need in your code to do any while, if the SQL statement
doesn't fail and triggers the die(), you can rest assured you'll get a
record with a single field, even if it only contains a null, that's the 
way

with variables, you can't fail on them, though they might return null.

Satyam


- Original Message -
*From:* Dan Shirah [EMAIL PROTECTED]
 *To:* Satyam [EMAIL PROTECTED]
*Sent:* Friday, March 23, 2007 7:14 PM
*Subject:* Re: [PHP] POST a variable


Satyam, I'm trying to retrieve the id using the identity method, but I do
not get anything returned.  Do you see anything wrong with this code?

$get_max = SELECT scope_identity();
  $max_result = mssql_query($get_max) or die(mssql_error());
  while($max=mssql_fetch_row($max_result)){
}
$max_id = $max[0];
  echo $max_id;


On 3/23/07, Satyam [EMAIL PROTECTED] wrote:

 Do a 'select @@identity', it will give you the last record id.  The gap
 in
 between steps 3 and 4, brief as it may seem, is enough to get you in
 trouble.

 Satyam



 - Original Message -
 From: Dan Shirah [EMAIL PROTECTED]
 To: Németh Zoltán  [EMAIL PROTECTED]
 Cc: php-general php-general@lists.php.net
 Sent: Friday, March 23, 2007 4:07 PM
 Subject: Re: [PHP] POST a variable


 The reason I have to use it as I posted is because I am using Microsoft
 SQL
 server instead of MySQL.  And I haven't found a php function for MSSQL
 that
 works the same as mysql_insert_id()

 So, to come out with a comparable function with pretty reliable results,
 I
 follow this process:

 1. User enters data into form
 2. User submits form
 3. Save page inserts info into the database
 4. Directly after the insert statement is my SELECT MAX query
 5. I assign the retrieved value to a hidden field
 6. I pass this value to the next form

 I figure the odds of another record being inserted inbetween the time it
 takes to go from step 3 to step 4 are very, very minimal.  We're talking
 about MAYBE a 2-3 millisecond gap?


 On 3/23/07, Németh Zoltán [EMAIL PROTECTED] wrote:
 
  2007. 03. 23, péntek

Re: [PHP] POST a variable

2007-03-23 Thread Dan Shirah

Ah, got it.

Thanks a lot for the help Satyam!


On 3/23/07, Satyam [EMAIL PROTECTED] wrote:


It seems to me @@identity should sufice, and it certainly does not need to
be any 'new' function, since it had been there for quite a while.  My
feeling is that those added functions might be used for elaborate stored
procedures, where you might be dealing with multiple tables or some fancy
administrative uses.  You certainly DON'T want any function that gives you
the last identity of some other connection!

$get_max = SELECT @@identity;
$max_result = mssql_query($get_max) or die(mssql_error());
$max_id = mssql_fetch_row($max_result);
echo $max_id[0];

Though the fetch will return only one record with only one field, it will
still return that as an array, even if it only contains one element, so
you
still need to add the [0].  Unfortunately, PHP doesn't allow the brackets
to
a function that returns an array.

You might use mssql_result instead:

$get_max = SELECT @@identity;
$max_result = mssql_query($get_max) or die(mssql_error());
$max_id = mssql_result($max_result,0,0);
echo $max_id;


Satyam

- Original Message -
From: Dan Shirah [EMAIL PROTECTED]
To: Satyam [EMAIL PROTECTED]
Cc: php-general php-general@lists.php.net
Sent: Friday, March 23, 2007 7:48 PM
Subject: Re: [PHP] POST a variable


Sorry, I was more tailoring my question to the syntax of my query.  It
wasn't displaying anything for my echo.

I've changed it to this now:

$get_max = SELECT scope_identity();
$max_result = mssql_query($get_max) or die(mssql_error());
$max_id = mssql_fetch_row($max_result);
echo $max_id;

But all my echo returns is array instead of the number.

Below are brief explanations of the different _identity uses you have.

SELECT *@@IDENTITY*
Returns the last IDENTITY value produced on a connection, regardless of
the
table that produced the value, and regardless of the scope of the
statement
that produced the value.

SELECT *IDENT_CURRENT(*'*tablename*'*)*
This new function returns the last IDENTITY value produced in a table,
regardless of the connection that created the value, and regardless of the
scope of the statement that produced the value.

SELECT *SCOPE_IDENTITY()*
This new function returns the last IDENTITY value produced on a connection
and by a statement in the same scope, regardless of the table that
produced
the value.


On 3/23/07, Satyam [EMAIL PROTECTED] wrote:

  I don't really know about the scope_identity() function, neither much
 about @@identity.  I know that the names preceded by @@ are MSSQL
internal
 variables and I think that is the one you are looking for, I just
checked
 in
 the on-line MS documentation, but have no SQL server active at this
 moment,
 nor have I dealt with one for the last few years, though I did use
 auto-increment fields and I certainly was able to retrieve the last id,
 somehow.  I might be wrong and there might be another function or
variable
 that gives you the value, but it looks to me @@identity is the one you
are
 looking for.

 There is no need in your code to do any while, if the SQL statement
 doesn't fail and triggers the die(), you can rest assured you'll get a
 record with a single field, even if it only contains a null, that's the
 way
 with variables, you can't fail on them, though they might return null.

 Satyam


 - Original Message -
 *From:* Dan Shirah [EMAIL PROTECTED]
  *To:* Satyam [EMAIL PROTECTED]
 *Sent:* Friday, March 23, 2007 7:14 PM
 *Subject:* Re: [PHP] POST a variable


 Satyam, I'm trying to retrieve the id using the identity method, but I
do
 not get anything returned.  Do you see anything wrong with this code?

 $get_max = SELECT scope_identity();
   $max_result = mssql_query($get_max) or die(mssql_error());
   while($max=mssql_fetch_row($max_result)){
 }
 $max_id = $max[0];
   echo $max_id;


 On 3/23/07, Satyam [EMAIL PROTECTED] wrote:
 
  Do a 'select @@identity', it will give you the last record id.  The
gap
  in
  between steps 3 and 4, brief as it may seem, is enough to get you in
  trouble.
 
  Satyam
 
 
 
  - Original Message -
  From: Dan Shirah [EMAIL PROTECTED]
  To: Németh Zoltán  [EMAIL PROTECTED]
  Cc: php-general php-general@lists.php.net
  Sent: Friday, March 23, 2007 4:07 PM
  Subject: Re: [PHP] POST a variable
 
 
  The reason I have to use it as I posted is because I am using
Microsoft
  SQL
  server instead of MySQL.  And I haven't found a php function for MSSQL
  that
  works the same as mysql_insert_id()
 
  So, to come out with a comparable function with pretty reliable
results,
  I
  follow this process:
 
  1. User enters data into form
  2. User submits form
  3. Save page inserts info into the database
  4. Directly after the insert statement is my SELECT MAX query
  5. I assign the retrieved value to a hidden field
  6. I pass this value to the next form
 
  I figure the odds of another record being inserted inbetween the time
it
  takes to go from step 3 to step 4 are very, very minimal

Re: [PHP] POST a variable

2007-03-23 Thread Børge Holen
On Friday 23 March 2007 15:45, Dan Shirah wrote:
 Okay, I feel like the correct answer to this is about 2mm back in my grey
 matter.

 1. I have a query that pulls the last row number when a newly inserted
 record is added:

 $maximum=SELECT MAX(payment_id) FROM payment_request;
   $max_result=mssql_query($maximum);
   while($max=mssql_fetch_row($max_result)){
   }
   $max_id = $max[0];

 2. I have multiple selections for the user to pick, but regardless of what
 they choose I want the $max_id variable to be passed to the next page.

 3.  Would I go about this by assigning $max_id to a hidden field like
 below?

 input type=hidden value=?php echo $max_id; ? size=5
 maxlength=10 name=max_id /

 4.  And then to retrieve this value on my next page just get it out of
 $_POST['max_id']  ??

 Does that all sound correct?

If it works correctly it probably is... 

-- 
---
Børge
Kennel Arivene 
http://www.arivene.net
---

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] POST a variable

2007-03-23 Thread Richard Lynch
On Fri, March 23, 2007 9:45 am, Dan Shirah wrote:
 Okay, I feel like the correct answer to this is about 2mm back in my
 grey
 matter.

 1. I have a query that pulls the last row number when a newly inserted
 record is added:

 $maximum=SELECT MAX(payment_id) FROM payment_request;
   $max_result=mssql_query($maximum);
   while($max=mssql_fetch_row($max_result)){
   }
   $max_id = $max[0];

DO NOT DO THIS!!!

As soon as *TWO* people hit your site at the same time, this will blow
up in your face.

Use this:
http://php.net/mysql_insert_id

 2. I have multiple selections for the user to pick, but regardless of
 what
 they choose I want the $max_id variable to be passed to the next page.

 3.  Would I go about this by assigning $max_id to a hidden field like
 below?

 input type=hidden value=?php echo $max_id; ? size=5
 maxlength=10 name=max_id /

Yes.

Though the size and maxlength are kinda silly on a hidden input...

 4.  And then to retrieve this value on my next page just get it out of
 $_POST['max_id']  ??

 Does that all sound correct?

Try it and see.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] POST a variable

2007-03-23 Thread Richard Lynch
On Fri, March 23, 2007 10:07 am, Dan Shirah wrote:
 The reason I have to use it as I posted is because I am using
 Microsoft SQL
 server instead of MySQL.  And I haven't found a php function for MSSQL
 that
 works the same as mysql_insert_id()

I guarantee that there is a way to do it in MSSQL, somehow...

I think it might be:

SELECT @INSERT;

Or maybe it was:

SELECT @@INSERT

Something like that.

Find a SQL Server list and ask them.  They'll know for sure.

 I figure the odds of another record being inserted inbetween the time
 it
 takes to go from step 3 to step 4 are very, very minimal.  We're
 talking
 about MAYBE a 2-3 millisecond gap?

No, we are NOT talking about a 2-3 millisecond gap.

As soon as your server gets even a little busy, your script is getting
interrupted by the other scripts trying to run, and you are just
playing russian roulette on whether it happens now or tomorrow that
you get this all messed up.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Post CGI variable to PHP

2002-01-10 Thread Benjamin Bostow

I am trying to pass variables from a CGI/Perl script
to a php page. I know how to pass it through the url
(i.e. page.php?tmp=[var1]tmp2=[var2]) but need to
know how to pass it so that the information does not
show up in the url. 

Benjamin

__
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]