Page 1 of 1

Posting Variables between PHP Programs

Posted: Fri Sep 08, 2006 9:00 pm
by Sid Rosenburg
Here is my issue (yes I am still newish to PHP/MYSQL)

I have 3 functions

1 select a record from a drop down list
2 display the record and modify elements of it
3 Issue a modify

Yes I know its a hifalluting way of modifying a record.

My code seems to work in 1 get a record from the file
but it wont do anything in 2 (wont display record for modification

Code is as follows

Code: Select all

<?php 
 

//
// This function  modifies  Petaluma Schedule entries
//
 

include 'config.php';  
include 'opendb.php';
 
// access existing Petaluma records

$sql = "SELECT date1, date2, date3 FROM petaluma"; 
$sql_result = mysql_query($sql, $conn) or die ("zero-connection to Database files");

if (!$sql_result) {
	echo "Problem with petaluma file in amend function";
} else {
echo "

<html>
<head> 
<title>PETALUMA SCHUDLE MODIFICATION</title>
 
</head>
<body>
<center>
<font face=arial>
<h3> Select a date from the list already available on File</h3> 

<FORM method=\"POST\" action=\"petaa.php\">
<table  cellspacing=5 cellpadding=5>
<tr>
<td align=left><strong>Petaluma Dates</strong></td>
<td  valign=top>
<select name=\"sel_record\">

<option value=\"\">Select date--</option>
";

while ($row=mysql_fetch_array($sql_result)) {

$date1 = $row["date1"];
$date2 = $row["date2"];
$date3 = $row["date3"];

echo  "
<option value=\"$date1\">$date1 : $date2 : $date3 </option>
";
}

echo "
</select>
</td>
</tr>
<tr><td colspan=2 align=center><INPUT type=\"submit\" value=\"Fetch Date\"></td>
</tr>
</table>
</FORM>

</body>
</html>
";

 }

// mysql_close($conn);


?>
and 2

Code: Select all

<?php 
 

// This function called from PETA.PHP   
// This function  will modify  Petaluma Schedule entry selected in PETA
// passes control to PETAAA to finish the job
 

include 'config.php';
include 'opendb.php';
 

// access existing Petaluma records
 
$sql = "SELECT date1, date2, date3, comment, status FROM petaluma WHERE date1 = \"$sel_record\""; 
$sql_result = mysql_query($sql, $conn) or die ("zero-connection to Database file");
  


if (!$sql_result) {
	echo "Problem with petaluma file in amend function";
} else {

$row = mysql_fetch_array($sql_result);
$dd1 = $row["date1"];
$dd2 = $row["date2"];
$dd3 = $row["date3"];

$cmt = $row["comment"];
$dlt = $row["delete"];
$sts = $row["status"];

echo "

<html>
<head> 
<title>PETALUMA SCHEDULE MODIFICATION</title> 
</head>
<body>
<center>
<font face=arial>
<h3> Modify the record.</h3> 


<FORM method=\"POST\" action=\"petaaa.php\">
\\ <input type=\"hidden\" name=\"sel_record\" value=\"$date1\">
<table cellspacing=5 cellpadding=5>
<tr><td><strong> Course Start Date : </strong></td>   <td> \"$dd1\"</td></tr>
<tr><td><strong> Date 2  </strong></td>               <td> \"$dd2\"</td></tr>
<tr><td><strong> Date 3  </strong></td>               <td> \"$dd3\"</td></tr>
<tr><td colspan=2><strong> <hr size=1></td></tr>


<tr>
<td><strong> Status : </strong> </td>
<td>
<SELECT name=\"status\">
<OPTION value=\"\">  </OPTION>
<option value="Course Full">Full</option>
<option value="Course Open">Open</option>
<option value="Delete">Delete</option>
</SELECT>
</td></tr>


<tr><td><strong> Comment : </strong></td><td> <INPUT type=\"text\" name=\"cmt"\ value=\"$cmt\" size=80></td><tr>

 
<tr><td colspan=2><INPUT type=\"submit\" value=\"Modify Course\"></td></tr>
</table>
</FORM>
</body>
</html>
";

 }

mysql_close($conn);


?>
I am sure its something simple I am missing but its late on Friday evening andI am wasted trying to solve this any assistance would be appreciated

Posted: Fri Sep 08, 2006 10:40 pm
by feyd
There are several unescaped double quotes in your output that would cause PHP to have parse errors. They have been highlighted in a sense by the forum's own highlighting.