UtamaBeritaTutorialBlogTool


Category: PHP

XML Parsing Error: XML or text declaration not at start of entity

Posted By: zainal on July, 11 2011

I encountered this error when tried to generate xml file from PHP:

XML Parsing Error: XML or text declaration not at start of entity
Location: http://www.ilmuit.com/feed.php?tutorial
Line Number 2, Column 1:

<?xml version=”1.0″ encoding=”ISO-8859-1″ ?>
^

When I view the page source, I notice there is a space before the xml header (see below). An extra white line just before the <?xml tag. That was the cause of the error message.

Most likely reason for this error is some white space before XML content. Probably there is a line break before the XML declaration at the top of the file. I checked all the PHP source code manually for unseen characters before the first <?php tag in every files including my config.php, mysql_connect.php, header.php and any other files that required to render the XML page.

Finally I fixed this by open the source file, and hit the backspace key to remove any whitespace, before <?php and after ?> php close tag.

Removing all the blank lines fixed the error and my feed started working fine. Hope this guide can help someone out.


No Comment | Category: PHP

How to Get Yahoo! Messenger Status using PHP

Posted By: zainal on June, 20 2011

Yahoo Messenger is a popular chat application that has been used by million people around the world. Here I provide simple PHP class you can to put on your website to indicate if you or your friend are online or offline on Yahoo! Messenger.

function ym($id){
$url = ‘http://opi.yahoo.com/online?u=’;
$data = file_get_contents($url . $id);
if (trim(strtolower(strip_tags($data))) != ‘user not specified.’) {
return (strlen($data) == 140) ? ‘online’ : ‘offline’;
} else {
return trim(strip_tags($data));
}
}

To use the class, just echo your yahoo id by using this code:

echo ym("yahoo_id"); //change your yahoo id here


No Comment | Category: Firefox, PHP

Cannot Load MySQL Extension

Posted By: zainal on April, 30 2007

If you are getting this error (Cannot Load MySQL Extension. Please check your PHP configuration) when running phpmyadmin with browser, you need to enable the mysql extension.

1) Edit your php.ini and make sure the following line was uncommented:

extension=php_mbstring.dll
extension=php_mysql.dll

2) Copy \PHP\libmysql.dll to the \windows\system32 if you were running mysql on windows.

3) Restart your server

You can use this simple script to test. It can tell you whether the mysql extensions is successfully loaded.

if (!@function_exists('mysql_get_server_info')) {
echo “Mysql is not loaded”;
}else{
echo “Mysql is successfully loaded”;
}

Technorati Tags: ,


7 Comments | Category: PHP

Curl and PHP5 on Windows

Posted By: zainal on February, 24 2007

I am trying to getting Curl to work properly on my Windows. I am getting this error when I try to load the php_curl.dll module:

Fatal error: Call to undefined function curl_init()

To fix this, copy libeay32.dll and ssleay32.dll from PHP\dll folder into c:\windows\system32. Override any existing file. Restart Apache server and this should fix the problem.


No Comment | Category: PHP

Port Scanner in PHP

Posted By: zainal on February, 05 2007

This is a very basic port scanner in PHP.

for($port = $from; $port <= $to; $port++)
{
$fp = fsockopen(”$host”, $port);
if ($fp)
{
print(”port $port opened \r”);
fclose($fp);
}


4 Comments | Category: PHP