?
Solved

query after update

Posted on 2005-03-23
7
Medium Priority
?
181 Views
Last Modified: 2012-05-05
Hi,

The update works fine. However the REC_NO is null trying to do an query after the update.

The only way I can get it to work is to hardcode the $REC_NO.


Any suggestions to this problem ?

Thanks


<?

// Make a MySQL Connection
mysql_connect("xx", "xx", "xx") or die(mysql_error());
mysql_select_db("design") or die(mysql_error());



if( isset($_POST["H_IL_FILM_AOI"]) ) {
   $set_part = 'SET H_IL_FILM_AOI_STAMP = NOW()';
   $stamp = " H_IL_FILM_AOI = 'yes'";
   

     }
else {
   $set_part = 'SET R_IL_FILM_AOI_STAMP = NOW()';
   $stamp = " H_IL_FILM_AOI = 'no'";
     }

//$REC_NO = 90;  //works
//$REC_NO = $_POST['REC_NO']; // no go
//$REC_NO = $_GET['REC_NO']; // no go
//$REC_NO = $_REQUEST['REC_NO']; //no go
//$xx = $_GET['REC_NO'];  //no go


mysql_query("UPDATE PROJECT $set_part, $stamp WHERE REC_NO = REC_NO") or die("Upate error : " . mysql_error());


$query= "select * from PROJECT WHERE REC_NO = $REC_NO";
echo $query;

?>

QUERY OUTPUT select * from PROJECT WHERE REC_NO=$REC_NO
0
Comment
Question by:jjcheap1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 2

Expert Comment

by:alberthendriks
ID: 13614465
Can you give us the code of the page that submits the REC_NO?
0
 

Author Comment

by:jjcheap1
ID: 13614586
<?php

// Connecting, selecting database
mysql_connect("xx", "xx", "Pxx") or die(mysql_error());
mysql_select_db("design") or die(mysql_error());
//echo 'Connected successfully';
mysql_select_db('design') or die('Could not select database');

// Performing SQL query
// debug mode
//$query = 'SELECT * FROM `PROJECT` where REC_NO=89';
$query = "select * from PROJECT where REC_NO='".$_GET['REC_NO']."'";
//run mode
$result = mysql_query($query) or die('Query failed: ' . mysql_error());

$num=mysql_num_rows($result);
$i=0;

// Count rows in database and assign variables to results

while ($i < $num) {
$REC_NO=mysql_result($result,$i,"REC_NO");
$CI_PART_NO=mysql_result($result,$i,"CI_PART_NO");
$FILE_NUMBER=mysql_result($result,$i,"FILE_NUMBER");
$RECEIVED_DATE=mysql_result($result,$i,"RECEIVED_DATE");
$H_IL_FILM_AOI=mysql_result($result,$i,"H_IL_FILM_AOI");
++$i;
}
?>


<title> Change AOI FILM HOLD... Design Services </title>
<form name="c1" method="post" action="11.php?$_GET['REC_NO']">
<h2>You are updating CI Part Number&nbsp;  <?=$CI_PART_NO?></h2>
<p>
<b>Is  Film on hold?&nbsp;&nbsp;&nbsp; <?=$H_IL_FILM_AOI?></b>
<p>
<B>If you want to place IL FILM on hold check box and click Change ! </b>
<p>
<b>If you want to release IL FILM hold click Change!</b>
<p>
<input type="checkbox" name="H_IL_FILM_AOI" onclick="checkDate(this.checked, '<?=$H_IL_FILM_AOI_STAMP?>', '<?=$R_IL_FILM_AOI_STAMP?>');" <?=$checkbox?>
<input type="submit" value="Change !" /></p>
</form>
0
 
LVL 8

Expert Comment

by:_Marcel_
ID: 13615811
Maybe

<form name="c1" method="post" action="11.php?REC_NO=<?=$REC_NO?>">

will give you REC_NO in the $_REQUEST (or $_POST)...
0
WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

 
LVL 2

Expert Comment

by:alberthendriks
ID: 13616353
I don't know what Marcel means exactly, but I think the problem is in that line. I'd say

<form name="c1" method="post" action="11.php?REC_NO=<?php echo $_GET['REC_NO']; ?>">

In the other file you can fetch it with GET or REQUEST.
0
 
LVL 4

Expert Comment

by:JKlatte
ID: 13618096
Marcel is right concerning the variable in the form line, since it comes from the line $REC_NO=mysql_result($result,$i,"REC_NO"); However, it's bad practice to call a form action with variables (11.php?...), since it mixes POST and GET requests. It should be like this:

  <form name="c1" method="POST" action="11.php">
  <input type="hidden" name="REC_NO" value="<?=$REC_NO?>">
  <input type="checkbox" name="H_IL_FILM_AOI" [...javascript...] > <?=$checkbox?>
  <input type="submit" value="Change !">


Then in 11.php, use $_POST['REC_NO'], since the form method is POST:

  mysql_query("UPDATE PROJECT $set_part, $stamp WHERE REC_NO = $_POST['REC_NO']");
 
0
 
LVL 8

Accepted Solution

by:
_Marcel_ earned 2000 total points
ID: 13619467
It might be indeed a bit confusing mixing GET and POST variables, but basically it will work. Sometimes with URL-rewriting it is even necessary...
0
 

Author Comment

by:jjcheap1
ID: 13645824
Marcel's

 Maybe

<form name="c1" method="post" action="11.php?REC_NO=<?=$REC_NO?>">

Worked !

I do not get to spend much time on this between "side shows".  

Thanks for all of your help

Scott
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question