Setup: I only have one database with one table in it. The first page has a form that adds a record (w/ 6 fields in it) to the mySQL database's lone table via PHP. This works fine. I also have a PHP table that displays all records in my database on this same page. This too works fine. I have my table set up so that there is a 7th field, called "rid" to act as a "record id" or unique identifying field. This is primary and auto-incremented. There is a second form on the same page that prompts the user to enter a "rid". One this form is submitted it loads a second PHP page that displays the fields of whichever record was specified by the "rid" and allows the user to edit them.
Problem: When this second PHP page's form is submitted, a third PHP page is supposed to UPDATE the mySQL table. It... doesn't, despite echoing that is has.
Second Page Code:
[code=php]
<?php
error_reporting (E_ALL);
ini_set('displa y_errors', true);
foreach($HTTP_P OST_VARS as $varname => $value)
$formVars[$varname]=$value;
$db1=mysql_conn ect("XXXXX","XX XXXXX","XXXXXXX ");
mysql_select_db ("tracking") ;
$query="SELECT * FROM job_status WHERE rid = \"".$formVar s["rid"]."\"";
$result=mysql_q uery($query);
$row=mysql_fetc h_array($result );
$formVars = array();
$formVars["bone"]=$row["bone"];
$formVars["ctwo"]=$row["ctwo"];
$formVars["lthree"]=$row["three"];
$formVars["rfour"]=$row["rfour"];
$formVars["ifive"]=$row["ifive"];
$formVars["fsix"]=$row["fsixl"];
$formVars["rid"]=$row["rid"];
mysql_close($db 1);
?>
<html>
<head>
<title>Job Status Update</title>
</head>
<body bgcolor="white" >
<form method="post" action="page3.p hp">
<table>
<col span="1" align="right">
<tr>
<td><font color="blue">Bo ne:</font></td>
<td><input type="text" name="bone"
value="<? echo $formVars["bone"]; ?>" size=100></td>
</tr>
<tr>
<td><font color="blue">Ct wo:</font></td>
<td><input type="text" name="ctwo"
value="<? echo $formVars["ctwo"]; ?>" size=100></td>
</tr>
<tr>
<td><font color="blue">Lt hree:</font></td>
<td><input type="text" name="lthree"
value="<? echo $formVars["lthree"]; ?>" size=100></td>
</tr>
<tr>
<td><font color="blue">Rf our:</font></td>
<td><input type="text" name="rfour"
value="<? echo $formVars["rfour"]; ?>" size=100></td>
</tr>
<tr>
<td><font color="blue">If ive:</font></td>
<td><input type="text" name="ifive"
value="<? echo $formVars["ifive"]; ?>" size=100></td>
</tr>
<tr>
<td><font color="blue">Fs ix:</font></td>
<td><input type="text" name="fsix"
value="<? echo $formVars["fsix"]; ?>" size=100></td>
</tr>
<tr>
<td><font color="blue">ri d:</font></td>
<td><input type="text" name="rid"
value="<? echo $formVars["rid"]; ?>" size=100></td>
</tr>
<tr>
</tr>
<tr>
<td><input type="submit" value="Submit"> </td>
</tr>
</body>
</html>
[/code]
Third Page Code:
[code=php]
<html>
<head>
<title>Job Status Updated</title>
</head>
<body bgcolor="white" >
<?php
foreach($HTTP_P OST_VARS as $varname => $value)
$formVars[$varname]=$value;
$db1=mysql_conn ect("XXXXXX","X XXXXX","XXXXXX" );
mysql_select_db ("tracking") ;
echo "Record updated<br><a href=\"tracking .php\">click here</a> to update another record<br>";
$query="UPDATE job_status set ".
"bone= \"".$formVar s["bone"]."\",".
"ctwo= \"".$formVar s["ctwo"]."\",".
"lthree= \"".$formVar s["lthree"]."\",".
"rfour= \"".$formVar s["rfour"]."\",".
"ifive= \"".$formVar s["ifive"]."\",".
"fsix= \"".$formVar s["fsix"]."\",".
"\" WHERE rid = \"".$formVar s["rid"]."\"" or die('<hr />MySQL Error: ' .mysql_error(). '<hr />');
mysql_query($qu ery);
mysql_close($db 1);
?>
</body>
</html>
[/code]
(I've removed the mysql_connect values from the code. I don't think the first page's code needs to be included as everything is passed perfectly fine from the first to the second and everything works fine on that page)
Can anyone provide any pointers on what I'm messing up? I'm new to PHP and I feel like I've made some dumb typo but just can't see it. (The table will update in PHPadmin perfectly fine)
Problem: When this second PHP page's form is submitted, a third PHP page is supposed to UPDATE the mySQL table. It... doesn't, despite echoing that is has.
Second Page Code:
[code=php]
<?php
error_reporting (E_ALL);
ini_set('displa y_errors', true);
foreach($HTTP_P OST_VARS as $varname => $value)
$formVars[$varname]=$value;
$db1=mysql_conn ect("XXXXX","XX XXXXX","XXXXXXX ");
mysql_select_db ("tracking") ;
$query="SELECT * FROM job_status WHERE rid = \"".$formVar s["rid"]."\"";
$result=mysql_q uery($query);
$row=mysql_fetc h_array($result );
$formVars = array();
$formVars["bone"]=$row["bone"];
$formVars["ctwo"]=$row["ctwo"];
$formVars["lthree"]=$row["three"];
$formVars["rfour"]=$row["rfour"];
$formVars["ifive"]=$row["ifive"];
$formVars["fsix"]=$row["fsixl"];
$formVars["rid"]=$row["rid"];
mysql_close($db 1);
?>
<html>
<head>
<title>Job Status Update</title>
</head>
<body bgcolor="white" >
<form method="post" action="page3.p hp">
<table>
<col span="1" align="right">
<tr>
<td><font color="blue">Bo ne:</font></td>
<td><input type="text" name="bone"
value="<? echo $formVars["bone"]; ?>" size=100></td>
</tr>
<tr>
<td><font color="blue">Ct wo:</font></td>
<td><input type="text" name="ctwo"
value="<? echo $formVars["ctwo"]; ?>" size=100></td>
</tr>
<tr>
<td><font color="blue">Lt hree:</font></td>
<td><input type="text" name="lthree"
value="<? echo $formVars["lthree"]; ?>" size=100></td>
</tr>
<tr>
<td><font color="blue">Rf our:</font></td>
<td><input type="text" name="rfour"
value="<? echo $formVars["rfour"]; ?>" size=100></td>
</tr>
<tr>
<td><font color="blue">If ive:</font></td>
<td><input type="text" name="ifive"
value="<? echo $formVars["ifive"]; ?>" size=100></td>
</tr>
<tr>
<td><font color="blue">Fs ix:</font></td>
<td><input type="text" name="fsix"
value="<? echo $formVars["fsix"]; ?>" size=100></td>
</tr>
<tr>
<td><font color="blue">ri d:</font></td>
<td><input type="text" name="rid"
value="<? echo $formVars["rid"]; ?>" size=100></td>
</tr>
<tr>
</tr>
<tr>
<td><input type="submit" value="Submit"> </td>
</tr>
</body>
</html>
[/code]
Third Page Code:
[code=php]
<html>
<head>
<title>Job Status Updated</title>
</head>
<body bgcolor="white" >
<?php
foreach($HTTP_P OST_VARS as $varname => $value)
$formVars[$varname]=$value;
$db1=mysql_conn ect("XXXXXX","X XXXXX","XXXXXX" );
mysql_select_db ("tracking") ;
echo "Record updated<br><a href=\"tracking .php\">click here</a> to update another record<br>";
$query="UPDATE job_status set ".
"bone= \"".$formVar s["bone"]."\",".
"ctwo= \"".$formVar s["ctwo"]."\",".
"lthree= \"".$formVar s["lthree"]."\",".
"rfour= \"".$formVar s["rfour"]."\",".
"ifive= \"".$formVar s["ifive"]."\",".
"fsix= \"".$formVar s["fsix"]."\",".
"\" WHERE rid = \"".$formVar s["rid"]."\"" or die('<hr />MySQL Error: ' .mysql_error(). '<hr />');
mysql_query($qu ery);
mysql_close($db 1);
?>
</body>
</html>
[/code]
(I've removed the mysql_connect values from the code. I don't think the first page's code needs to be included as everything is passed perfectly fine from the first to the second and everything works fine on that page)
Can anyone provide any pointers on what I'm messing up? I'm new to PHP and I feel like I've made some dumb typo but just can't see it. (The table will update in PHPadmin perfectly fine)
Comment