undefined function imagecreatefromjpeg()

Call to undefined function imagecreatefromjpeg() in /home/materi/prog/cms_study/admin/pageuploadadd.php on line 88
 
Yes, that message show up when my friend try to access web based application.

I think thats my fault 🙂

Doing preliminary check :

edp# pkg_info | grep php5-gd
edit /etc/make.conf

PERL_VER=5.8.8
PERL_VERSION=5.8.8
WITHOUT_X11=yes

save.

edp# whereis php5-gd
php5-gd: /usr/ports/graphics/php5-gd
edp# cd /usr/ports/graphics/php5-gd && make install

edp# apachectl restart
done.

That message disappear 🙂

change wordpress password manually

Reset wordpress password using provided link not work, sadly no phpmyadmin available 🙂

Fortunately I have shell access which is enough, using built in md5 function to generate and update the password, here’s the steps:

1. Creating md5

– Using shell

Just type :

md5 -s your chosen password

– Make php script with this content :

<?php

$string=’your chosen password’;

echo md5($string);

?>

save this script and execute on your server.

2. Update wordpress table

– Using shell

login to mysql with username and password that written in wp-config.php

mysql -uusername -ppassword -pdatabase_name;

use database_name;

update user table set password=’md5 generated hash’ where username=’current_username’;

– Using php script

Make this script

<?php

$con=mysql_connect(“localhost”,”username_db”,”password_db”);

$choose=mysql_select_db(“db_name”);

//updating table

$update=mysql_query(“update table_user set password=’md5 generated hash’ where username=’current_username'”);

?>

save this script as change.php, upload to server and execute.

Done.

I can login to my wordpress account again.

$this and php

Little mistake on naming variable make me confuse for almost an hour.

$this

yes, $this is built-in variable that often use in OOP. By using $this, we refer to self referencing variable.

More in php.net manual

<?php
class A
{
function
foo()
{
if (isset(
$this)) {
echo
'$this is defined (';
echo
get_class($this);
echo
")\n";
} else {
echo
"\$this is not defined.\n";
}
}
}

class B
{
function
bar()
{
A::foo();
}
}

$a = new A();
$a->foo();
A::foo();
$b = new B();
$b->bar();
B::bar();
?>

in PHP | 88 Words

Install PHP6, easy install in windows

PHP6, I thought I already have latest one. 5.2.6 but I’m wrong 🙂

Quick way to try PHP6 is by installing Appserv 2.6.0, click here to download php 6.0.0-dev

Installation process is the same as other appserv series :

1. Double click installer

php6 Continue reading

in PHP | 120 Words

Setting path for PHP CLI

What is that for?

my friend asked my a question after lunch.

Well, install php using file from php.net don’t automatically set environment path for php location.

As result we must type full location of php.exe each time we must execute php from command line.

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Administrator>php -v
PHP 5.2.3 (cli) (built: May 31 2007 09:37:22)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

C:\Documents and Settings\Administrator>cd ..

C:\Documents and Settings>php -v
PHP 5.2.3 (cli) (built: May 31 2007 09:37:22)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

C:\Documents and Settings>d:

D:\>php -v
PHP 5.2.3 (cli) (built: May 31 2007 09:37:22)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

D:\>

Yes, by setting path for php we can execute php.exe from any place in windows.

To set that path, just right click on My Computer:

Click Advance

Environment variables for input php location.

I install php in c:\php.

Click OK.

Done 🙂

in PHP | 188 Words