I have the below code, one is the page to enter the item number and the other is to extract it from a AS400 using a ODBC connection. I seem to get a error when trying to get the data. I can't seem to see where I'm missing something. Any help would be appreciated.
Thanks,
HTML page to get input from user.
<HTML>
<head>
<TITLE> Test </TITLE>
</HEAD>
<BODY>
<FORM action="itemchk1.php" method="GET" >
Item no: <INPUT type="text" name="item" /><BR/>
<INPUT type="submit" value="Get It" />
</form>
</BODY>
</HTML>
// PHP to connect and get the data.
<head>
<title>ODBC Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<table width="75%" border="1" cellspacing="1" cellpadding="1" bgcolor="#FFFFFF">
<tr bgcolor="#CCFFFF">
<td height="22"><b>Item No</b></td>
<td height="22"><b>Description</b></td>
<td height="22"><b>Size</b></td>
</tr>
<?php
$login = "";
$pass = "";
$ODBCName = "Conn1";
$itemid = $_Get['item'];
//connect to the database
$conn = odbc_connect($ODBCName,$login,$pass);
echo "connect: $conn";
if ($conn <=0){
echo "Error in connection<BR>";
exit;
}else{
echo "<p>Connection successful\n";
}
//SQL query
$query = "SELECT FPITMMAS.ITMNUM, FPITMMAS.ITDESC, FPITMMAS.ITSIZE from
FPITMMAS where FPITMMAS.ITMNUM=$itemid";
//execute query
$result = odbc_exec($conn, $query);
//query database
while(odbc_fetch_row($result))
{
$itemno = odbc_result($result, 1);
$desc = odbc_result($result, 2);
$size = odbc_result($result, 3);
//format results
print ("<tr>");
print ("<td>$itemno</td>");
print ("<td>$desc</td>");
print ("<td>$size</td>");
print ("</tr>");
}
//disconnect from database
odbc_close($conn);
?>
</table>
</body>
</html>