Archive

Archive for the ‘Uncategorized’ Category

List of Browser Safe Fonts

December 2nd, 2010 No comments

Just sharing the link I found: common fonts for all browsers. We have recently had issues with a site, designed in Calibri. It’s a pity, but that font doesn’t work for Windows XP, that’s why we had to revert it to standard fonts. Hope it saves you some time.

Categories: Uncategorized Tags:

How to Check that a PHP Variable is a Mysql Resource

October 15th, 2010 No comments

When you create something related to mysql, it is always important to verify that your variables contain the things you expect. Here are some code lines that will allow you to verify whether your variables are mysql resources or not.

The first way to verify that we deal with the resource is to check it with is_resource php function. Here is the sample form PHP official website:

$db_link = @mysql_connect('localhost', 'mysql_user', 'mysql_pass');
if (!is_resource($db_link)) {
die('Can\'t connect : ' . mysql_error());
}

?>

When we know that our variable contain a resource, we need to ensure that it is a mysql resource. Another PHP function will help us to do this. It’s get_resource_type().

$c = mysql_connect();
$restype=get_resource_type($c);
if (stristr($restype, "mysql")) echo "OK";
?>

This will check the resource type and will return OK if it is a mysql resource. So the final check will look like:

if (is_resource($db_link) && stristr($db_link, “mysql”)) echo “OK”;

This way you will be sure that you have a mysql resource associated with your variable.

How to Add MySQL Root Password for Directadmin

October 15th, 2010 No comments

Recently I had to deal with a Directadmin VPS that had mysql installed, but for some reason there wasn’t a record for root in mysql user table. Here are the queries I used to add a root account, and to assign all the necessary privilegies.

First of all We need to create a record with username and password.

INSERT INTO user(user, password) values (‘root’, PASSWORD(‘PASSWORD_HERE’));

Then we need to add all the privileges to our root:

UPDATE `mysql`.`user` SET `Select_priv` = ‘Y’,
`Insert_priv` = ‘Y’,
`Update_priv` = ‘Y’,
`Delete_priv` = ‘Y’,
`Create_priv` = ‘Y’,
`Drop_priv` = ‘Y’,
`Reload_priv` = ‘Y’,
`Shutdown_priv` = ‘Y’,
`Process_priv` = ‘Y’,
`File_priv` = ‘Y’,
`Grant_priv` = ‘Y’,
`References_priv` = ‘Y’,
`Index_priv` = ‘Y’,
`Alter_priv` = ‘Y’,
`Show_db_priv` = ‘Y’,
`Super_priv` = ‘Y’,
`Create_tmp_table_priv` = ‘Y’,
`Lock_tables_priv` = ‘Y’,
`Execute_priv` = ‘Y’,
`Repl_slave_priv` = ‘Y’,
`Repl_client_priv` = ‘Y’,
`Create_view_priv` = ‘Y’,
`Show_view_priv` = ‘Y’,
`Create_routine_priv` = ‘Y’,
`Alter_routine_priv` = ‘Y’,
`Create_user_priv` = ‘Y’ WHERE `user`.`Host` = ” AND `user`.`User` = ‘root’ LIMIT 1 ;

And the last command:

GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY ‘PASSWORD_HERE’ WITH GRANT OPTION

Then you can do the same for da_admin mysql user:

GRANT ALL PRIVILEGES ON *.* TO da_admin@localhost IDENTIFIED BY ‘PASSWORD_HERE’ WITH GRANT OPTION;

Restart mysql and have fun.

Optimized MySQL Configuration File my.cnf for Directadmin

October 1st, 2010 No comments

Here is a sample configuration file with optimized default values for Directadmin. If your server load is average, it should suit your needs. Please, note, that this configuration is ready for MySQL 4, not for MySQL 5.

[mysqld]
local-infile=0
skip-locking
query_cache_limit=1M
query_cache_size=32M
query_cache_type=1
max_connections=500
interactive_timeout=100
wait_timeout=100
connect_timeout=10
thread_cache_size=128
key_buffer=16M
join_buffer=1M
max_allowed_packet=16M
table_cache=1024
record_buffer=1M
sort_buffer_size=2M
read_buffer_size=2M
max_connect_errors=10
# Try number of CPU’s*2 for thread_concurrency
thread_concurrency=2
myisam_sort_buffer_size=64M
server-id=1

[safe_mysqld]
err-log=/var/log/mysqld.log
open_files_limit=8192

[mysqldump]
quick
max_allowed_packet=16M

[mysql]
no-auto-rehash
#safe-updates

[isamchk]
key_buffer=64M
sort_buffer=64M
read_buffer=16M
write_buffer=16M

[myisamchk]
key_buffer=64M
sort_buffer=64M
read_buffer=16M
write_buffer=16M

[mysqlhotcopy]
interactive-timeout

Categories: Uncategorized Tags: