473,472 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem in PHP-GTK application

Hi,
I m vishal jayaswal. I m doing my BE from Agra and i m working on PHP.
At present i m creating an small application for adding two numbers.
Enter forst number in one text box and second number in other text
box. When you click the button Result, sum of both the number thta are
entered in both the text boxes, shown in result text box. but this
code create an error when i run this code:

<?
if (!class_exists('gtk'))
{
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
dl('php_gtk.dll');
else
dl('php_gtk.so');
}
function delete_event()
{
return false;
}
function destroy()
{
Gtk::main_quit();
}
function result($button, $window)
{
$gettext1 = $ent1->get_text();
$gettext2 = $ent2->get_text();
$result = $gettext1 + $gettext2;
$ent3->set_text($result);
}
function test1()
{
global $window;
global $ent1;
global $ent2;
global $ent3;
$window->destroy();
}
$window = &new GtkWindow();
$window->set_name('Main Window');
$window->set_title('Introduction to PHP-GTK');
$window->connect('destroy', 'destroy');
$window->connect('delete_event', 'delete_event');
$window->set_border_width(5);
$window->set_position(GTK_WIN_POS_CENTER);
$frame = &new GtkFrame('Calculator');
$window->add($frame);
$table = &new GtkTable(3, 2, false);
$frame->add($table);
$num1 = &new GtkLabel('Number1: ');
$num2 = &new GtkLabel('Number2: ');
$ent1 = &new GtkEntry();
$ent2 = &new GtkEntry();
$ent3 = &new GtkEntry();
$button = &new GtkButton('Result');
$button->connect('clicked', 'result', '$window');
$table->attach($num1,0,1,0,1);
$table->attach($num2,0,1,1,2);
$table->attach($button,0,1,2,3);
$table->attach($ent1,1,2,0,1);
$table->attach($ent2,1,2,1,2);
$table->attach($ent3,1,2,2,3);
$window->show_all();
Gtk::main();
?>

Error Occured:

C:\php4>php c:\php4\test\test1.php
Fatal error: Call to a member function on a non-object in
c:\php4\test\test1.php
on line 23

Please send me the solution of this problem.
Jul 16 '05 #1
1 2369
bi***********@yahoo.com (Vishal Jayaswal) wrote in
news:ba*************************@posting.google.co m:
Hi,
I m vishal jayaswal. I m doing my BE from Agra and i m working on PHP.
At present i m creating an small application for adding two numbers.
Enter forst number in one text box and second number in other text
box. When you click the button Result, sum of both the number thta are
entered in both the text boxes, shown in result text box. but this
code create an error when i run this code:

<?
if (!class_exists('gtk'))
...


The problem is function 'result'.

In this function the global declarations of '$ent1', '$ent2', '$ent2' are
not present.

This is the correct version:

function result($button, $window)
{
global $ent1;
global $ent2;
global $ent3;
$gettext1 = $ent1->get_text();
$gettext2 = $ent2->get_text();
$result = $gettext1 + $gettext2;
$ent3->set_text($result);
}

-------------------------
Roberto
http://rsoftware.altervista.org

Jul 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Bruce W...1 | last post by:
In my effort to learn PHP I'm playing with some simple email scripts. They worked a few days ago but they stopped working. The only thing I've done to this Windows 2000 PC in this time was a...
18
by: ZoombyWoof | last post by:
Hi. Im very new to php, and I have a problem here that I cant find the solution for. I have problems with session variables, I want some variables to maintain their value between different php...
6
by: Zaan | last post by:
www.entropy.ch release for Mac OS X.] Hello, My issue is the following: to promote consistency on a site I'm building, I decided to go for a php scheme where some recurring elements...
9
by: Bartosz Wegrzyn | last post by:
I need help with sessions. I createt set of web site for nav with authorization. first I go into main.php which looks like this: <?php //common functions include_once '../login/common.php';...
3
by: Tyrone Slothrop | last post by:
The first question, is this even possible? What I need to do is pass the contents of a PHP web page from a textarea using window.open method to a new browser window and display it. The page has...
3
by: stclaus | last post by:
Hi, I'm currently experiencing a problem using sessions under php 4.4.2. I store variables and objects inside session variables, and all works well under php 5.x, but when I upload those pages to...
0
by: deacon57 | last post by:
FYI - If you are a computer scientist (or geek), this post may be for you. I wanted to log any search keywords, etc that are used on my site. I created a simple program that logs search terms...
3
by: webandwe | last post by:
Hi, I got form that let you state a folder name, on sumbit thw script creates the folder with the name you stated, the problem is I want it to upload the php file "view.php" when the folder is...
2
by: swethak | last post by:
Hi, I am getting the problem the problem with google map in Internet Explorer. This map worked fine in mozilla . When i opened the same map in Internet Explorer i am getting the error...
4
by: liberty1 | last post by:
Hi everyone. I appreciate your effort at helping newbies like me. I have the following problems and will appreciate urgent help. PROBLEM NUMBER 1: Using PHP and MySQL, I am able to upload...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.