FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


SELECT UUID() not supported





Aredon
In one of my PHP files I am using:
Code:

function UUID(){
mysql_result( mysql_query("SELECT UUID()") ,0 );
}

that works fine with my localhost running MySQL 5.0.18.

However frih.net is running MySQL 4.0.23 and the UUID function was only added to MySQL since 4.1. I am now looking to define a similar PHP function than can generate a string using the same syntax and length as:
Code:

6ccd780c-baba-1026-9564-0040f4311e29
hexkid
Aredon wrote:
I am now looking to define a similar PHP function than can generate a string using the same syntax and length as:
Code:

6ccd780c-baba-1026-9564-0040f4311e29


uniqid()
Also check PECL :: Package :: uuid.

Code:
<?php
function UUID_like() {
  $x = md5(uniqid(rand(), true));
  return preg_replace('/^(.{8})(.{4})(.{4})(.{4})(.{12})$/', '$1-$2-$3-$4-$5', $x);
}
?>
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.