WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : A database abstraction layer for the PHP 3.0 ODBC module. It supports persistent connections, fetching rows into arrays, prepare/execute (variable binding) and has a new and improved error interface.
Categories : Databases, PHP, Complete Programs Update Picture
Stig Bakken
Date : Jan 17th 1999
Grade : 2 of 5 (graded 3 times)
Viewed : 17422
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Stig Bakken
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?php // -*- C++ -*-
/*
* $Id: db-odbc.phl,v 1.7 1998/10/01 18:41:56 ssb Exp $
*/

$db_error_code = 0;
$db_error_msg = false;
$db_error_source = false;

/**
* @function db_connect
* @purpose Connect to a database
* @desc
* Connects to a database and returns and identifier for the connection.
* @arg database
* Data source name or database host to connect to.
* @arg user
* Name of user to connect as.
* @arg password
* The user's password.
*/
function db_connect($dsn, $user, $password)
{
$ret = @odbc_connect($dsn, $user, $password);
if (!$ret) {
db_check_errors($php_errormsg);
return false;
}
return $ret;
}

/*
* Function: db_query
* Arguments: $conn (int) - connection identifier
* $query (string) - SQL statement to execute
* Description: executes an SQL statement
* Returns: (int) 0 - query failed
* 1 - query succeeded
*/
function db_query($conn, $query)
{
$ret = @odbc_exec($conn, $query);
if (!$ret) {
db_check_errors($php_errormsg);
return false;
}
return $ret;
}

/*
* Function: db_fetch_row
* Arguments: $result (int) - result identifier
* Description: Returns an array containing data from a fetched row.
* Returns: false - error
* (array) - returned row
*/
function db_fetch_row($result)
{
$row = array();
$cols = @odbc_fetch_into($result, &$row);
if (!$cols) {
db_check_errors($php_errormsg);
return false;
}
return $row;
}

/*
* Function: db_free_result
* Arguments: $result (int) - result identifier
* Description: Frees all memory associated with a result identifier.
* Returns: (int) 0 - failure
* 1 - success
*/
function db_free_result($result)
{
$ret = @odbc_free_result($result);
db_check_errors($php_errormsg);
return $ret;
}

/*
* Function: db_disconnect
* Arguments: $connection (int) - connection identifier
* Description: closes a database connection
* Returns: (int) 0 - failure
* 1 - success
*/
function db_disconnect($connection)
{
$ret = @odbc_close($connection);
db_check_errors($php_errormsg);
return $ret;
}

/*
* Function: db_autocommit
* Arguments: $connection (int) - connection identifier
* Description: turn autocommit on or off
* Returns: (int) 0 - failure
* 1 - success
*/
function db_autocommit($connection, $enabled)
{
$ret = @odbc_autocommit($connection, $enabled);
db_check_errors($php_errormsg);
return $ret;
}


function db_commit($connection)
{
$ret = @odbc_commit($connection);
db_check_errors($php_errormsg);
return $ret;
}


function db_rollback($connection)
{
$ret = @odbc_rollback($connection);
db_check_errors($php_errormsg);
return $ret;
}


function db_quote_string($string)
{
$ret = ereg_replace( "'", "''", $string);
return $ret;
}


function db_prepare($connection, $query)
{
$ret = @odbc_prepare($connection, $query);
db_check_errors($php_errormsg);
return $ret;
}


function db_execute($statement, $data)
{
$ret = @odbc_execute($statement, $data);
db_check_errors($php_errormsg);
return $ret;
}


function db_error_code()
{
global $db_error_code;
return $db_error_code;
}


function db_error_msg()
{
global $db_error_msg;
return $db_error_msg;
}


function db_error_source()
{
global $db_error_source;
return $db_error_source;
}


function db_check_errors($errormsg)
{
global $db_error_code, $db_error_msg, $db_error_source;
if (ereg( 'SQL error: (\[.*\]\[.*\]\[.*\])(.*), SQL state (.....)',
$errormsg, &$data)) {
list($foo, $db_error_source, $db_error_msg, $db_error_code) = $data;
} else {
$db_error_msg = $db_error_source = false;
$db_error_code = 0;
}
}


function db_post_error($code, $message)
{
global $db_error_code, $db_error_msg, $db_error_source;
$db_error_code = $code;
$db_error_msg = $message;
$db_error_source = "[PHP][ODBC][db-odbc]";
}


function db_api_version()
{
return 10; // 1.0
}

?>



This program allows you to upload an ODBC ressource - i.e. an MS-Access database to a MySQL server.
Categories : Databases, MySQL, Complete Programs, PHP, Databases
Education Center is a set of PHP-scripts to administer a corporate education and examination system via Internet/intranet written in PHP for MySQL.
Categories : PHP, Databases, MySQL, Complete Programs
Dynamic WHERE CLAUSE depending on number of FORM FIELDS
Categories : ODBC, General SQL, PHP, Complete Programs, Databases
myCSV-dump converts a simple CSV-flatfile-database into an MySQL-dump.
Categories : PHP, MySQL, Databases, Complete Programs
AITSH Download
Categories : PHP, Complete Programs, MySQL, Databases
phpAddQuote v1.2 - UPDATED! Lets users add their own quotes to your website. You specify how many quotes appear on the page at a time. Easier install!
Categories : HTML and PHP, Complete Programs, PHP, Databases, Personalization and Membership
Shopping Basket On-Line Ordering System.
Categories : Complete Programs, MySQL, PHP, Ecommerce, Databases
An SQL Administration User Interface for the Web
Categories : Databases, PHP, mSQL, Complete Programs
DDN FFA Network Script
Categories : PHP, MySQL, Complete Programs, HTML and PHP, Databases
Web Self Service Resource Scheduler Using Session Variables under php4 includes Calendar building code - requires MySQL
Categories : PHP, Complete Programs, Calendar, MySQL, Databases
DirtSearch Version 3.5 full function robust PHP and MySQL (and other databases) Site or Web Wide Search Engine
Categories : PHP, MySQL, Complete Programs, Search, Databases
Simple Mini Poll class library (SimPoll)
Categories : PHP, PHP Classes, Databases, MySQL, Complete Programs
BBS system for easy customization. Utilizes mySQL.
Categories : Complete Programs, MySQL, PHP, Databases
Browse a MySQL database & draw a tree view & load final items into a template page.
Categories : MySQL, Complete Programs, Algorithms, PHP, Databases
databases administration remote Web
Categories : mSQL, PHP, Complete Programs, Databases