Login Retreive lost passwordRegister
Search

Manual  /  Functions  /  Database Functions  /  SetConnectionResource

SetConnectionResource
SetConnectionResource (
resource $conn
string $table
string $type = null 
)

Arguments:

Name Description
$conn The connection resource used for the database.
$table The name of the table where the values should loaded from and stored in.
$type The type of database you are connecting to. The default is set in the configuration file with the var FH_DEFAULT_DB_TYPE.

Description:

Set the connection resource which should be used for the database connection.

This function is implemented since v1.0 on 17 oct 2005.
The arguments $conn and $table are switched since 26 oct 2006. However, the old way still works for
backwards compatibility.

Note: You can only use these functions if you make use of the dbFormHandler class! So, include class.dbFormHandler.php and create a new FormHandler object with the constructor dbFormHandler().

Note: If you want to create a new connection, please use dbInfo() and dbConnect().

Example

<?php 
/** 
* Your Database Connection (In This Example MySQL) 
*/ 
$connection mysql_connect"localhost""username""password" ); 

// connection made ? 
if( $connection 

    
// select the database 
    
if( !mysql_select_db"database"$connection ) ) 
    { 
        
// could not select database! 
        
die('Could not select the database! Error: ' mysql_error() ); 
    } 

// could not connect to the database 
else 

    die(
'Could not make a connection to the database! Error: ' mysql_error() ); 


// include the formhandler 
include('FH3/class.dbFormHandler.php'); 

// create a new form 
$form = new dbFormHandler(); 

// set the database info 
$form -> setConnectionResource$connection"myTable""mysql" ); 

// fields.. 
$form -> textField('Test''myField'FH_STRING ); 

// here comes the rest of the form 
// ............ 

// set the data handler 
// (NOTE the onSaved, this is different then onCorrect!) 
$form -> onSaved("doSomething"); 

// display the form 
$form -> flush(); 

// the data handler... 
// NOTE the two arguments!!!! 
function doSomething$id$data 

    
// do something here... 


?>

See also: dbFormHandler  |  dbInfo  |  dbConnect

Latest change: 05 March 10 / 08:56

Comments

powered by PHP-GLOBE   © 2004 - 2024 FormHandler. All rights reserved.   -   Open source license