• Welcome, Guest. Please login.
 
May 07, 2021, 10:58:17 PM

News:

Welcome to the SQLitening support forums!


SQLite function from mysql

Started by ud3webdev, June 30, 2012, 11:56:51 AM

Previous topic - Next topic

ud3webdev

hi im working on a little system here that was built for mysql and now its joining a sqlite database
and im looking for the functions that works with sqlite and not mysql
im looking for:
mysql_fetch_assoc conversion to sqlite
mysql_result conversion to sqlite

this was my code of what i thought the correct functions were, but does not work with sqlite yet.
<?php
function is_admin($user_id) {
$user_id = (int)$user_id;
return (
sqlite_num_rows(sqlite_query("SELECT COUNT(`user_id`) FROM `users` WHERE `user_id` = $user_id AND `type` = 1")
0) == 1) ? true false;
}
function 
change_password($user_id$aegispass) {
$user_id = (int)$user_id;
$aegispass md5($aegispass);
sqlite_query("UPDATE `users` SET `aegispass` = '$aegispass' WHERE `user_id` = '$user_id'");
}
function 
register_user($register_data) {
array_walk($register_data'array_sanitize');
$register_data['aegispass'] = md5($register_data['aegispass']);
$feilds '`' implode('`, `'array_keys($register_data)) . '`';
$data '\'' implode('\', \''$register_data) . '\'';
sqlite_query("INSERT INTO `users` ($feilds) VALUES ($data)");
}
function 
setup_user($extension$aegispass) {
$aegispass md5($_POST['aegispass']);
sqlite_query("UPDATE `users` SET `aegispass` = '$aegispass' WHERE `extension` = '$extension'");
}
function 
user_data($user_id) {
$data = array();
$user_id = (int)$user_id;
$func_num_args func_num_args();
$func_get_args func_get_args();
if ($func_num_args 1) {
unset($func_get_args[0]);
$feilds '`' implode('`, `'$func_get_args) . '`';
$data sqlite_fetch_array(sqlite_query("SELECT $feilds FROM `users` WHERE `user_id` = $user_id"));
return $data;
}
}
function 
logged_in() {
return (isset($_SESSION['user_id'])) ? true false;
}
function 
user_exists($extension) {
$extension sanitize($extension);
return (sqlite_num_rows(sqlite_query(" SELECT COUNT(`user_id`) FROM `users` WHERE `extension` = '$extension'"), 0) == 1) ? true false;
}
/*function email_exists($email) {
$email = sanitize($email);
return (mysql_result(mysql_query(" SELECT COUNT(`user_id`) FROM `users` WHERE `email` = '$email'"), 0) == 1) ? true : false;
}*/
function user_active($extension) {
$extension sanitize($extension);
return (sqlite_num_rows(sqlite_query(" SELECT COUNT(`user_id`) FROM `users` WHERE `extension` = '$extension' AND `active` = 1"), 0) == 1) ? true false;
}
function 
user_id_from_username($extension) {
$extension sanitize($extension);
return sqlite_num_rows(sqlite_query("SELECT `user_id` FROM `users` WHERE `extension` = '$extension'"), 0'user_id');
}
function 
login($extension$aegispass) {
$user_id user_id_from_username($extension);
$extension sanitize($extension);
$aegispass md5($aegispass);
return (sqlite_num_rows(sqlite_query("SELECT COUNT(`user_id`) FROM `users` WHERE `extension` = '$extension' AND `aegispass` = '$aegispass'"), 0) == 1) ? $user_id false;
}
?>