non-object problem.
| From: | Miles Phillips | Date: | Wed, 01 May 2002 20:11:14 +0000 |
| Subject: | non-object problem. | ||
| Groups: | php.gtk.general | ||
| Request: | Send a blank email to php-gtk-general+get-1893@lists.php.net to get a copy of this message | ||
Pasted below is a code example I am using. The edit function queries a
database and pulls up information and populates gtkEntry boxes. When
the update button is clicked, it is supposed to pass those entry box
values to the update function. However, I get the call to a member
function on a non-object fatal error. I am obviously missing something
in my code, because the values are not getting passed. If anyone would
like to point out my probably obvious mistake, it would be greatly
appreciated.
Miles Phillips
function update() {
global $entFName,$entLName,$entPhone,$entAttendees;
$updFn=$entFName->get_text();
$updLn=$entLName->get_text();
$updPn=$entPhone->get_text();
$updAt=$entAttendees->get_text();
$sql="update tblAttendees set contactFName=\"$updFn\",
contactLName=\"$updLn\"
phone=\"$updPn\", $attn=\"$updAt\" where
Id='$Id'";
print "\n$sql\n";
//query($sql);
}
function edit($Id) {
connect();
$sql="select contactFName, contactLName, phone, attendees,
cancel from tblAttendees where Id='$Id'";
$run=query($sql);
while($row=mysql_fetch_array($run)) {
$fname=$row['contactFName'];
$lname=$row['contactLName'];
$phone=$row['phone'];
$attendees=$row['attendees'];
$cancel=$row['cancel'];
}
print "Id=$Id - FN=$fname - LN=$lname - Phone=$phone -
Attendees=$attendees\n";
$wdwEdit=&new gtkWindow();
$wdwEdit->set_title('Edit Attendee');
$wdwEdit->set_default_size(500,75);
$vbox=&new gtkVBox(false, 2);
$wdwEdit->add($vbox);
$lblFn=&new GtkLabel("First Name");
$lblLn=&new GtkLabel("Last Name");
$lblPn=&new GtkLabel("Phone");
$lblAt=&new GtkLabel("Attendees");
$entFName=&new gtkEntry();
$entFName->set_text($fname);
$entLName=&new gtkEntry();
$entLName->set_text($lname);
$entPhone=&new gtkEntry();
$entPhone->set_text($phone);
$entAttendees=&new gtkEntry();
$entAttendees->set_text($attendees);
$entBtn=&new gtkButton('Update');
$entBtn->connect_object('clicked','update',$Id);
$table=&new GtkTable(6,3,false);
$vbox->add($table);
$table->attach($lblFn,1,2,1,2, GTK_EXPAND|GTK_FILL, GTK_SHRINK);
$table->attach($lblLn,2,3,1,2, GTK_EXPAND|GTK_FILL, GTK_SHRINK);
$table->attach($lblPn,3,4,1,2, GTK_EXPAND|GTK_FILL, GTK_SHRINK);
$table->attach($lblAt,4,5,1,2, GTK_EXPAND|GTK_FILL, GTK_SHRINK);
$table->attach($entFName,1,2,2,3, GTK_EXPAND|GTK_FILL
,GTK_SHRINK);
$table->attach($entLName,2,3,2,3, GTK_EXPAND|GTK_FILL,
GTK_SHRINK);
$table->attach($entPhone,3,4,2,3, GTK_EXPAND|GTK_FILL,
GTK_SHRINK);
$table->attach($entAttendees,4,5,2,3, GTK_EXPAND|GTK_FILL,
GTK_SHRINK);
$table->attach($entBtn,5,6,2,3, GTK_EXPAND|GTK_FILL,
GTK_SHRINK);
$wdwEdit->show_all();
}