I am using PHP 4.2.1, Windows 2000P, IIS4 connected to an Access 2000
database with an ISAPI module. I have created a very simple form and have
written a function to display radio buttons. While a hard-coded, HTML
version of the form works perfectly (correctly returning data), the php file
brings up an error message when I simply add the function definition at the
top of the page (whether or not the function call is present in the code
further down).
i.e.,
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
T_STRING or T_VARIABLE or T_NUM_STRING in
C:\inetpub\wwwroot\PHP\cat_proto3.php on line 46
Line 46 corresponds to the form tag, as follows:
<FORM ACTION="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
The entire code is below:
<HTML>
<HEAD>
<TITLE>Prototype IOM Meteorite Catalog Access Site</TITLE>
</HEAD>
<?php
###############################PROGRAM
FUNCTIONS#####################################
############################################################################
#########
#Function MakeRadioButtons()
function
MakeRadioButtons($Name,$Current,$Values=array(1,0),$Prompt=array("Yes","No")
)
{
for($Index=1;$Index<=count($Prompt);$Index++) {
$String.=<<< STRING
$Prompt[$Index]: <INPUT TYPE="RADIO" NAME="$Name" VALUE="$Values[$Index]"
STRING;
$String .= ($Prompt[$Index]==$Current) ? " Checked>"
: ">";
$String .= "\n";
} #end of for loop
return chop($String);
} #end of function MakeRadioButtons()
############################################################################
#########
?>
<BODY bgcolor="#FF8000">
<!--
********************FORM************************************************ -->
<!--
************************************************************************ -->
<!-- if this is the first entry on the page, present the initial form -->
<?php
if (!isset($_POST[menu])){
?>
<div align="center"><H2>INSTITUTE OF METEORITICS<br>
Prototype Meteorite Catalog Access Page</H2>
<hr></div>
<br>PLEASE SELECT A METEORITE CLASS:
<FORM ACTION="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
<?php
MakeRadioButtons("meteorite_class", "1", array("1","2","3","4"),
array("Chondrite","Achondrite","Stony Iron","Iron"));
?>
<BR><input type="radio" name="meteorite_class" value="1">Chondrite
<BR><input type="radio" name="meteorite_class" value="2">Achondrite
<BR><input type="radio" name="meteorite_class" value="3">Stony Iron
<BR><input type="radio" name="meteorite_class" value="4">Iron
<br><input type="hidden" name="menu" value="no">
<BR><INPUT TYPE="submit" VALUE="Next">
</FORM>
<!--
****************OUTPUT************************************************** -->
<!--
************************************************************************ -->
<!-- if the user has entered basic form data, present the output -->
<?php
}
else
{
echo <<<OUTPUT_HEADER
<br><br>
<div align="center"><h2>Meteorite Catalog Output
Results</h2></div>
<hr>
<br><br>
OUTPUT_HEADER;
echo <<<TABLEHEADER
<table width="500px" border="1" cellspacing="1" cellpadding="1"
bgcolor="#FFFF80" align="center">
<tr>
<td height="22" align="left"><b>Sample Name</b></td>
<td height="22" align="left"><b>Type</b></td>
</tr>
TABLEHEADER;
//connect to database
$connectionstring = odbc_connect("meteoritecatalog", "wbhk", "poitiers");
$class_query = "SELECT sample.Sample, type.type_name
FROM sample,type
WHERE sample.type = type.type
AND sample.type=$_POST[meteorite_class]
ORDER BY type.type_name";
//execute query
$queryexe = odbc_do($connectionstring, $class_query);
//query database
while(odbc_fetch_row($queryexe))
{
$msample = odbc_result($queryexe, 1);
$mtype = odbc_result($queryexe, 2);
//format results
print ("<tr>");
print ("<td>$msample</td>");
print ("<td>$mtype</td>");
print ("</tr>");
}
//disconnect from the database
odbc_close($connectionstring);
print ("</table>");
}
?>
</BODY>
</HTML>
Many thanks for the help, Bill
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php