unexpected T_VARIABLE
| From: | Ed Holland | Date: | Wed, 15 May 2002 19:40:54 +0000 |
| Subject: | unexpected T_VARIABLE | ||
| Groups: | php.gtk.general | ||
| Request: | Send a blank email to php-gtk-general+get-1989@lists.php.net to get a copy of this message | ||
I seem to have a problem with unexpected T_VARIABLE's, I have used this code before, with only
minor changes, and I cant see any errors, so if anyone has any ideas I'd be grateful.
<code>
<?php
// Load the PHP-GTK extension
$extension = "php_gtk" . (strpos(PHP_OS, "WIN") >= 0 ? ".dll" :
".so");
dl($extension);
// Create a new window
$window = &new GtkWindow();
$window->set_title("Add Users");
$window->set_usize(300, 150);
$window->set_position(GTK_WIN_POS_CENTER);
$window->set_policy(false, false, false);
// Set a callback function for the destroy signal
$window->connect("destroy", "killwin");
function killwin()
{
echo("Window Destroyed!\n");
gtk::main_quit();
}
//add a vbox
$box = &new gtkvbox();
$window->add($box);
//add the 2 text boxes and button
$user = &new GtkEntry();
$user->set_text("User-Name!");
$box->pack_start($user);
$pass = &new GtkEntry();
$pass->set_text("Pass!")
$box->pack_start($pass);
$axx = &new GtkEntry();
$axx->set_text("Access!");
$box->pack_start($axx);
$button = &new gtkbutton(Add User!);
$button->connect("clicked", "adduser");
$box->pack_start($button);
function kill_window($butt,$win){
$win->destroy();
}
//add news function
function addnews($thebutton) {
global $user;
global $pass;
global $axx;
global $host;
global $user;
global $pass;
$usertxt = $user->get_chars(0, -1);
$passtxt = $pass->get_chars(0, -1);
$axxtext = $axx->get_chars(0, -1);
$length = strlen($userstxt) + strlen($passtxt) + strlen($axxtext) + strlen($user) + strlen($pass) +
28;
$post = $post . "POST http://" . $host . "/adduser.php
HTTP/1.0\n";
$post = $post . "User-Agent: Add User Bot 0.1\n";
$post = $post . "Referer: http://" . $host .
"/adduser.php\n";
$post = $post . "Content-Type: application/x-www-form-urlencoded\n";
$post = $post . "Host: http://localhost\n";
$post = $post . "Content-Length: $length" . "\n";
$post = $post . "Proxy -Connection: Keep -Alive\n\n";
$post = $post . "user=" . $headtxt . "&pass=" . $newstxt .
"&axx=" . $axx . "&user=" . $user . "&pass=" . $pass .
"\n";
echo $user;
echo $pass;
$fp=@fsockopen($host,80);
if(!$fp){
$message_to_display = "Error Connecting to Server!";
$title_to_display = "Error";
DisplayPopUp($message_to_display,$title_to_display);
}else{
fputs($fp,$post);
$data_amount = 1024;
while (!feof($fp)) {
$data=fgets($fp,$data_amount);
//if (!ereg("^News", $data)) { $data = ""; }
$data = str_replace("/n","\n",$data);
echo $data;
echo "\n";
$message_to_display = $data;
$title_to_display = "Return Message:";
if (ereg("^News", $data)) { DisplayPopUp($message_to_display,$title_to_display); }
}
fclose($fp);
}
}
function DisplayPopUp($message,$title){
$dialog = &new GtkDialog();
$dialog->set_title($title);
$dialog->set_border_width(0);
$dialog->set_policy(false, false, true);
$vbox = $dialog->vbox;
$vbox_widgets = $vbox -> children();
$vbox -> remove($vbox_widgets[0]);
$vbox_widgets[0] -> destroy();
$action_area = $dialog->action_area;
foreach ($action_area -> children() as $area_widget) {
$action_area -> remove($area_widget);
$area_widget -> destroy();
}
$button = &new GtkButton("OK");
$button->set_flags(GTK_CAN_DEFAULT);
$button -> connect('clicked','kill_window', $dialog);
$action_area->pack_start($button, true, true, 0);
$button->grab_default();
$button->show();
$label = new GtkLabel($message);
$label->set_padding(5,5);
$label->set_line_wrap(true);
$label->set_usize(300,(strlen($message) /10) * 10);
$vbox->pack_start($label, true, true, 0);
$label->show();
$dialog -> show();
$dialog -> set_modal(true);
}
// Show the window
$window->show_all();
// Start the main PHP-GTK listener loop
gtk::main();
?>
</code>
BTW i'm a HUGE newbie, so please donut take the mick too much :D.
Thanks
Ed Holland