Hello,
I have a script thats already done however I'm just missing sql file that need to be imported into the database in either for the script to run. How to creat a sql using this:
Code:
if (!defined('STARTED'))
die('No direct access.');
/**
* Connects to database.
*/
function tinyConnect($host, $userName, $passWord, $dataBase)
{
if (($con = mysql_connect($host, $userName, $passWord)) === false) {
trigger_error('Failed to connect to database. Error: ' . mysql_error(), E_USER_ERROR);
return false;
}
if (!mysql_select_db($dataBase, $con)) {
trigger_error('Failed to select database. Error: ' . mysql_error($con), E_USER_ERROR);
return false;
}
return $con;
}
/**
* Disconects.
*/
function tinyDisconnect(&$db)
{
if (mysql_close($db))
unset($db);
else
trigger_error('MySQL error: ' . mysql_error(), E_USER_WARNING);
}
/**
* Do query.
*/
function tinyQuery($query)
{
global $db;
if (!($rez = mysql_query($query, $db))) {
trigger_error('SQL Query error: ' . mysql_error(), E_USER_WARNING);
return false;
}
return $rez;
}
/**
* Insert data to table.
*/
function tinyInsert($table, $fields)
{
global $db;
if (!is_array($fields)) {
return false;
}
$sql = 'INSERT INTO `' . tinyEscape($table) . '` (';
$tmp = 'VALUES (';
foreach ($fields as $field => $value) {
$sql .= '`' . tinyEscape($field) . '`, ';
$tmp .= "'" . tinyEscape($value) . "', ";
}
$sql = substr($sql, 0, -2) . ') ' . substr($tmp, 0, -2) . ')';
if (!mysql_query($sql, $db)) {
trigger_error('SQL Query error: ' . mysql_error(), E_USER_WARNING);
return false;
}
Thank you all