| px | top | add code | search | signup | login | help |
function data_put($cmd,$database)
<?php
// Title: Data Put database connection abstraction function
// Author: William E. "haplo" Dunn Jr. haplo@epithna.com
// Version: 1.0 Tanis Release
// History: 1.0 Initial Code Release Works
// ToDo: Verify if a return of true and false instead of 1 or 0 is allowed php syntax
//
//used for Inserts where the Identity row value is not needed or Updates returns 0 or 1
//Function assumes the use of the local host and a common web user which is used to
//access the databases
{
//First establish a connection to the sql server by connection ID in $datacon
$datacon = mysql_connect("database server","sql login","sql login password");
//make the requested database the active db uses $datacon to reference the connection
mysql_select_db($database, $datacon);
//use datacon to send query to the server uses sql $cmd string passed
//$resut will be false if the query fails
$result = mysql_query($cmd,$datacon);
//test to see to see if the query succeeded and return true or false to the calling code in case
//we want to take action passed on that information
if (!$result)
{
//query failed return false by returning a 0, false also seems to be vaild syntax but I
//cannot verify its not just a fluke that it works, all my references just say 1 or 0
return 0;
}
else
{
//we didn't get a false result query suceeded so return true a 1
return 1;
}
} //end of data_put function
php?>
Comments or questions?
PX is running PHP 5.2.11
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.