com_create_guid() function got error on server side but works fine in local using php
You can create GUIDs manually:
function getGUID(){
if (function_exists('com_create_guid')){
return com_create_guid();
}
else {
mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
$charid = strtoupper(md5(uniqid(rand(), true)));
$hyphen = chr(45);// "-"
$uuid = chr(123)// "{"
.substr($charid, 0, 8).$hyphen
.substr($charid, 8, 4).$hyphen
.substr($charid,12, 4).$hyphen
.substr($charid,16, 4).$hyphen
.substr($charid,20,12)
.chr(125);// "}"
return $uuid;
}
}
Usage:
$GUID = getGUID();
echo $GUID;
Follow:
http://guid.us/GUID/PHP
http://php.net/manual/en/function.com-create-guid.php
To extend the partially correct answers above:
taken from http://php.net/manual/en/com.installation.php
"From PHP 5.4.5, COM and DOTNET is no longer built into the php core. You have to add COM support in php.ini"
extension=php_com_dotnet.dll
You must be running PHP version less than 5 else you must be running on a LINUX box as COM is a windows based extension.
Try this script and make sure.
echo function_exists('com_create_guid')
? "Yes" + com_create_guid()
: "Nope !"
;