| Subcribe via RSS

b2evo fatal error: Allowed memory size

June 9th, 2008 | No Comments | Posted in b2evo, php by dreamluverz


In case you encounter this error upon installing b2evo you can check the solution below.

Error: Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 35 bytes) in /var/www/…/_misc/_plugins.class.php on line 2399

Solution: In most cases you have your php.iniĀ  inside the installed folder of b2evo, increase the allowed memory size and it will fix the error.

Tags: ,

What is utf8

May 27th, 2008 | No Comments | Posted in anything under the moonlight, mysql, php by dreamluverz

What Is UTF-8 And Why Is It Important?



Unicode is a character set supported across many commonly used software applications and operating systems. For example, many popular web browser, e-mail, and word processing applications support Unicode. Operating systems that support Unicode include Solaris Operating Environment, Linux, Microsoft Windows 2000, and Apple’s Mac OS X. Applications that support Unicode are often capable of displaying multiple languages and scripts within the same document. In a multilingual office or business setting, Unicode’s importance as a universal character set cannot be overlooked.

source: http://developers.sun.com/dev/gadc/technicalpublications/articles/utf8.html

Tags:

reciprocal link checker script

May 20th, 2008 | No Comments | Posted in php by dreamluverz

I found this code for reciprocal link checker on http://forums.digitalpoint.com/showthread.php?t=111

maybe you want to give it a shot. gudluck :)

<?php $mydomain = “www.domain.com”; // Set this to your domain $list = file_get_contents(“sites.txt”); $urls = explode (\n, $list); ini_set (default_socket_timeout, “5″); echo “<B>Checking back links to $mydomain….</B><P><FONT SIZE=-1>”; foreach ($urls as $url) { if (strlen ($url) && $url{0} != “#”) { echo $url . “<B><FONT COLOR=”; if (strpos (file_get_contents($url), $mydomain) != FALSE) { echo “GREEN> Found”; } else { echo “RED> Missing”; } echo “</FONT></B><BR>”; } } echo “</FONT>”; ?>
Tags: , , ,

xml 2 array and array to xml

May 12th, 2008 | No Comments | Posted in php by dreamluverz

I’ve tried this function with google feed but doesn’t seem to work. I haven’t look into details of it yet anyways you can try it and give it a shot. You can also use this for array to xml. Just check the link of the original post for more info.

PHP: XML to Array and backwards

Here the XML with PHP solution: XML->Array and Array->XML.
Work with it as with usual array.

Format XML->Array
_c - children
_v - value
_a - attributes

This is 1.1 :)

Example #1 (1.xml):

<ddd>
<onemore dd="55">
<tt>333</tt>
<tt ss="s1">555</tt>
<tt>777</tt>
</onemore>
<two>sdf rr</two>
</ddd>

The code:


$xml=xml2ary(file_get_contents(‘1.xml’));
print_r($xml);

Here is the Array result:


Array
(
[ddd] => Array (
[_c] => Array (
[onemore] => Array (
[_a] => Array (
[dd] => 55
)
[_c] => Array (
[tt] => Array (
[0] => Array (
[_v] => 333
)
[1] => Array (
[_a] => Array (
[ss] => s1
)
[_v] => 555
)
[2] => Array (
[_v] => 777
)
)
)
)
[two] => Array (
[_v] => sdf rr
)
)
)
)

function xml2ary(&$string) {
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parse_into_struct($parser, $string, $vals, $index);
xml_parser_free($parser);

$mnary=array();
$ary=&$mnary;
foreach ($vals as $r) {
$t=$r[‘tag’];
if ($r[‘type’]==‘open’) {
if (isset($ary[$t])) {
if (isset($ary[$t][0])) $ary[$t][]=array(); else $ary[$t]=array($ary[$t], array());
$cv=&$ary[$t][count($ary[$t])-1];
} else $cv=&$ary[$t];
if (isset($r[‘attributes’])) {foreach ($r[‘attributes’] as $k=>$v) $cv[‘_a’][$k]=$v;}
$cv[‘_c’]=array();
$cv[‘_c’][‘_p’]=&$ary;
$ary=&$cv[‘_c’];

} elseif ($r[‘type’]==‘complete’) {
if (isset($ary[$t])) { // same as open
if (isset($ary[$t][0])) $ary[$t][]=array(); else $ary[$t]=array($ary[$t], array());
$cv=&$ary[$t][count($ary[$t])-1];
} else $cv=&$ary[$t];
if (isset($r[‘attributes’])) {foreach ($r[‘attributes’] as $k=>$v) $cv[‘_a’][$k]=$v;}
$cv[‘_v’]=(isset($r[‘value’]) ? $r[‘value’] : ”);

} elseif ($r[‘type’]==‘close’) {
$ary=&$ary[‘_p’];
}
}

_del_p($mnary);
return $mnary;
}

// _Internal: Remove recursion in result array
function _del_p(&$ary) {
foreach ($ary as $k=>$v) {
if ($k===‘_p’) unset($ary[$k]);
elseif (is_array($ary[$k])) _del_p($ary[$k]);
}
}

// Array to XML
function ary2xml($cary, $d=0, $forcetag=) {
$res=array();
foreach ($cary as $tag=>$r) {
if (isset($r[0])) {
$res[]=ary2xml($r, $d, $tag);
} else {
if ($forcetag) $tag=$forcetag;
$sp=str_repeat(“\t”, $d);
$res[]=“$sp<$tag”;
if (isset($r[‘_a’])) {foreach ($r[‘_a’] as $at=>$av) $res[]=” $at=\”$av\”";}
$res[]=“>”.((isset($r[‘_c’])) ? “\n” : ”);
if (isset($r[‘_c’])) $res[]=ary2xml($r[‘_c’], $d+1);
elseif (isset($r[‘_v’])) $res[]=$r[‘_v’];
$res[]=(isset($r[‘_c’]) ? $sp : ”).“</$tag>\n”;
}

}
return implode(, $res);
}

// Insert element into array
function ins2ary(&$ary, $element, $pos) {
$ar1=array_slice($ary, 0, $pos); $ar1[]=$element;
$ary=array_merge($ar1, array_slice($ary, $pos));
}

source: http://mysrc.blogspot.com/2007/02/php-xml-to-array-and-backwards.html

Tags: , , ,

Call-time pass-by-reference has been deprecated

April 12th, 2008 | No Comments | Posted in anything under the moonlight, php by dreamluverz

Got this error and after some digging I found a solution. It was listed below. But looking back into my code I noticed that I called the function twice and used it incorrectly that caused the error!. :P Anyways, aside from that in case you encountered this error you can have the solution below :D

Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of [runtime function name](). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer

Solution:

For the Warning: Call-time pass-by-reference, in c:\EasyPhp\apache
\php.ini set :
allow_call_time_pass_reference = true
Tags: , , ,

[function.main]: failed to open stream: Permission denied

March 4th, 2008 | No Comments | Posted in php by dreamluverz

Warning: … [function.main]: failed to open stream: Permission denied

Warning: main() [function.include]: Failed opening … for inclusion (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in …

I wanna bear in mind that this error has something to do with file permission coz at first glance I just checked the path of the included file but looking closely it has something to do with the file permission. Changing it to 755 solved the issue. :P

And one more thing, I had this error_reporting(E_ALL && ~NOTICES); on my script and can’t see why my included file is not functioning. I’ve been looking what could be the error. Commented this error_reporting(E_ALL && ~NOTICES); kuala!!! I found the Warning msg! :P so be sure to comment this line when debugging your code or else you’ll get crazy looking for the error :P

Tags: , , ,

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]:

March 2nd, 2008 | No Comments | Posted in anything under the moonlight, php by dreamluverz

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user ‘apache’@'localhost’ (using password: NO)…

I’m having that error for using mysql_real_escape_string in one of my functions. Checked php manual and it says u need to have mysql connection to use that. :P well.. my bad…coz I’m using it in a variable before putting in a query. This is an example on how to use it anyway…


// Connect
$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
OR die(mysql_error());

// Query
$query = sprintf(”SELECT * FROM users WHERE user=’%s’ AND password=’%s’”,
mysql_real_escape_string($user),
mysql_real_escape_string($password));
?>

Tags: , , ,

[function.move-uploaded-file]: failed to open stream: Permission denied

February 24th, 2008 | 1 Comment | Posted in php by dreamluverz

[function.move-uploaded-file]: failed to open stream: Permission denied

Encountered this error. I’ve checked the path, permission it’s all correct. Then I tried changing the permission of the folder on where to move the files to 777… problem solved. Thanks God! :)

Tags: , ,

Virtual Class — cannot instantiate

February 23rd, 2008 | No Comments | Posted in php by dreamluverz

I’m getting this error Virtual Class — cannot instantiate within nested class/functions. I checked the class reported by the error and instead of using extended class when using other class inside that specific class, I used class::function, it solved problem.

Tags: , , ,

[function.getimagesize]:could not make seekable

February 21st, 2008 | No Comments | Posted in php by dreamluverz

I’m getting this error using the function getimagesize: [function.getimagesize]:could not make seekable

I’ve checked the path it’s right, checked if the image existed. It was. I took a closer look on the details of getimagesize on php manual for the accepted file types and it says jpg file type and mine was jpeg. MOdified it using photoshop to jpg file type and it solved my prob :)

Tags: , , , ,