I have just been doing PHP for a week and have a problem with odbc. I get "Warning: Supplied argument is not a valid ODBC-Link resource" when using odbc_exec and odbc_close. I have looked for silly typos etc but script looks alright to me. Here it is:
<?php
/ Mark Beal
03/09/02
This script will retrive appropriate entries from the database
according to a search term specified in search_form.php
/
phpinfo();
function HTML_head() {
//Top of page html stuff
echo "
<html><head>
<title>Epic Software Library</title>
</head>
<body bgcolor=\"#FFFFFF\" topmargin=0 leftmargin=0>";
}
function HTML_foot() {
//Bottom of page html stuff
echo "
</body></html>";
}
function Database_Connect() {
//Connect to the database
$cnx = odbc_connect("EpicSoftwareLibrary","","");
if (!cnx) {
Error_handler( "Error in odbc_connect" , $cnx );
}
}
function Select_Row() {
//Send odbc query
$cur = odbc_exec($cnx,"SELECT Manufacturer FROM software" );
if (!$cur) {
Error_handler( "Error in odbc_exec( no cursor returned ) " , $cnx );
}
}
function Error_handler( $msg, $cnx) {
echo "$msg \n";
odbc_close($cnx);
exit();
}
function Close_DB () {
odbc_close($cnx);
}
//Run the functions
HTML_head();
Database_Connect();
Select_Row();
Close_DB();
HTML_foot();
?>
The script is unfinished, I want to get a successful db connection before I carry on.
Any help would be much appreciated.