$text="Item ".$artnr." was inserted in the shopping cart";
}else{
$text="Insert failure of item ".$artnr." into the shopping cart";
}
echo $text;
There is a minor difference between these functions in returning values:
mysql_query()
returns a resource identifier only for
SELECT,SHOW,EXPLAIN
or
DESCRIBE
statements, and returns a
false
if the query was not executed
correctly. For other type of SQL statements,
mysql_query()
returns
true
on
success and
false
on error.
odbc_exec() returns a result identifier if the SQL command was executed
successfully and
false
if an error occurs.
Disconnecting database
Example 7 28 and Example 7 29 show the disconnect functions using the
MySQL library and the ODBC library.
Example 7 28 Disconnecting MySQL database
$db = mysql_connect($db_host, $db_user, $db_pass)
or die("Could not connect: " . mysql_error());
echo "Connected successfully";
mysql_close($db);
Example 7 29 Disconnecting DB2 database
$db=odbc_connect($datab,$db_user,$db_pass) or die("Could not connect ".
odbc_errormsg());
echo "Connected successfully";
odbc_close($db);
Note:
Using
mysql_close()
or odbc_close() is usually not necessary when
databases are used that do not support transactions as non persistent open
links are automatically closed, and the associated memory is freed at the end
of the script's execution.
There is a difference between both functions in returning values. The function
mysql_close()
returns
true
on success and
false
on failure. The function
odbc_close()
does not return any value. In rare cases the return value of the
mysql_close()
function is not used at all (see note above), therefore the
conversion if necessary at all can mostly be done by simply replacing the
function or inserting the new function at the end of program execution.
182
MySQL to DB2 UDB Conversion Guide
footer
Our partners:
PHP: Hypertext Preprocessor Cheap Web Hosting
JSP Web Hosting
Ontario Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Java Hosting
Cheapest Hosting
Visionwebhosting.net Business web hosting division of Vision Web Hosting Inc.. All rights reserved