martin5211 37 Posting Whiz in Training

Have you tried if(saw == "") ?

martin5211 37 Posting Whiz in Training

Create a JAR file, it is executable in almost all brand new computers with Java Runtime Environment installed.

martin5211 37 Posting Whiz in Training

I found some errors in your code:

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
		The Main class creates the GUI for the Dorm and 
		Meal charges.
 */
public class Main extends JFrame
{
	private JPanel dormPanel;
	private JComboBox dormBox;
	private JPanel mealPanel;
	private JComboBox mealBox;
	private JPanel totalChargesPanel;
	private JPanel selectedMealPanel;
	private JPanel buttonPanel;
	private JButton calcButton;
	private JLabel label1;
	private JTextField totalCharges;

	private String[] dorm = { "Allen Hall: $1,500 per semester", 
			"Pike Hall: $1,600 per semester", 
			"Farthing Hall: $1,200 per semester", 
	"University Suites: $1,800 per semester"};

	private String[] meal = { "7 meals per week: $650 per semester", 
			"14 meals per week: $1,095 per semester", 
	"Unlimited meals: $1,500 per semester"};

	/**
   		Constructor
	 */
	public Main()
	{
		super("Dormitory and Meal Plan");

		// Specify an action for the close button.
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		// Create a BorderLayout manager.
		setLayout(new BorderLayout());

		// Create the dorm and meal panel.      
		buildDormPanel();
		buildMealPanel();
		buildSelectedTotalChargesPanel();
		buildButtonPanel();

		// Add the components to the content pane.   
		add(dormPanel, BorderLayout.WEST);
		add(mealPanel, BorderLayout.EAST);
		add(totalChargesPanel, BorderLayout.SOUTH);
		add(buttonPanel, BorderLayout.NORTH);

		// Pack the contents of the window and display it.    
		pack();
		setVisible(true);
	}

	// The buildDormPanel method builds the dorm panel.	
	private void buildDormPanel()
	{
		// Create the dorm panel.      
		dormPanel = new JPanel();
		dormBox = new JComboBox(dorm);

		// Register the action listener.      
		dormBox.addActionListener(new ComboBoxListener());

		// Add the dorm panel to the panel.
		dormPanel.add(dormBox);
	}

	// The buildMealPanel method builds the meal panel.	
	private void buildMealPanel()
	{
		// Create the meal panel. …
martin5211 37 Posting Whiz in Training

Post the issue in a separate thread. Post the code and we'll try to fix it.

martin5211 37 Posting Whiz in Training

This can be solved using a trim function from client-side, Javascript.

martin5211 37 Posting Whiz in Training

Maybe, I'm using different application server and browser. Use trim() to remove leading/trailing spaces in ContactServlet:

request.setAttribute("emailState", email.trim());
martin5211 37 Posting Whiz in Training

I can't reproduce the error. Any other hint you could give me?

martin5211 37 Posting Whiz in Training

Do you have insert privileges into that database?

martin5211 37 Posting Whiz in Training

An extremely complex filter maybe could perform a domain check and a smtp validation but that can be slow... and that could take time to develop.

martin5211 37 Posting Whiz in Training

That happens because before <% if (s != null && s.equals("Songs")) out.println("selected=\"selected\""); %> there is an extra > symbol, needs to be removed on each case.

martin5211 37 Posting Whiz in Training

Remove Selected="True" and add > after the value on line 4

martin5211 37 Posting Whiz in Training
<% if s != null && (s.equals("Songs"))

There's a missing parenthesis, should be:

<% if (s != null && s.equals("Songs"))

Do the same in the other cases.

martin5211 37 Posting Whiz in Training

Add s != null && before s.equals("Option3") on each condition

martin5211 37 Posting Whiz in Training

It's easy, use a condition on each option.

<% String s = (String) request.getAttribute("subState"); %>
    <option value=""><fmt:message key="help.text.choose"/></option>
    <option value="Help" <% if (s.equals("Help")) out.println("selected=\"selected\""); %>><fmt:message key="help.text.help"/></option>
    <option value="Other" <% if (s.equals("Other")) out.println("selected=\"selected\""); %>><fmt:message key="help.text.other"/></option>

Instead of using RequestDispatcher object in ContactServlet for the success page, redirect to the same contact form, send an attribute with request.setAttribute() , then finally in the contact form is practical to use a condition (check the attribute isn't null), to display the message.

martin5211 37 Posting Whiz in Training

I'm sorry, I forgot to add test(email) in the condition that send the email.

package net.sourceforge.subsonic.controller;

import java.io.IOException;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.mail.*;
import javax.mail.internet.*;

public class ContactServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
	
		
	String email = request.getParameter("email");
	String subject = request.getParameter("subject");
	String message = request.getParameter("message");
		
	request.setAttribute("emailState", email);
	request.setAttribute("subState", subject);
	request.setAttribute("msgState", message);
	
	if (email.isEmpty()){
		request.setAttribute("err_email", "Please proivde a email");
	}
	if (!test(email)){
		request.setAttribute("err_email", "Provided incorrect email");
	}
	if (message.isEmpty()){
		request.setAttribute("err_msg", "Please provide a message");
	}
	if (subject.isEmpty()){
		request.setAttribute("err_sub", "Please provide a subject");
	}
	
		
		if(!email.isEmpty() && !message.isEmpty() && !subject.isEmpty() && test(email)){
			Properties props = new Properties();
			props.put("mail.smtp.host", "mysmptserver.com");
			props.put("mail.smtp.port", "587");
			
	        	Session session = Session.getDefaultInstance(props, null);
			
		try {
	                Message m = new MimeMessage(session);
	                m.setFrom(new InternetAddress(email, ""));
	                m.addRecipient(Message.RecipientType.TO, new InternetAddress("myadress@mydomain.com", ""));
	                m.setSubject(subject);
	                m.setText(message);
	                Transport.send(m);

	        } catch (AddressException e) {
	        	e.printStackTrace();
	        } catch (javax.mail.MessagingException e) {
		        e.printStackTrace();
		}
	        
		RequestDispatcher view = request.getRequestDispatcher("success.jsp");
			
		view.forward(request, response);
		
			}else{
		RequestDispatcher view = request.getRequestDispatcher("contact.jsp");
			
		view.forward(request, response);
			
			

		}
	}
	public static boolean test(String str){
		String reg = "[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})";
		Pattern p = Pattern.compile(reg);
		Matcher m = p.matcher(str);
		while(m.find())
		{
			String s1 = m.group(0);
			if (str == s1) return true;
		}

		return false;
	}

}

Contact form:

<form action="Contact.do" method="get">
    <p>Your email address: <input name="email" value="<% if(request.getAttribute("emailState") != null) out.println(request.getAttribute("emailState")); %>"></p><% if(request.getAttribute("err_email") != null) out.println(request.getAttribute("err_email")); %>
    <p>Mail subject: <input name="subject" value="<% if(request.getAttribute("subState") != null) out.println(request.getAttribute("subState")); %>"><% if(request.getAttribute("err_sub") != null) out.println(request.getAttribute("err_sub")); %></p>
    <p>Mail message: <textarea name="message"><% if(request.getAttribute("msgState") != null) out.println(request.getAttribute("msgState")); %></textarea><% if(request.getAttribute("err_msg") != null) out.println(request.getAttribute("err_msg")); %></p>
    <p><input type="submit"></p>
</form>
martin5211 37 Posting Whiz in Training

To save the information of each field use request.setAttribute("emailState", email) and then out.println(request.getAttribute("emailState")) on the input value (contact form), very similar to the procedure to pass errors.

martin5211 37 Posting Whiz in Training

There is missing two imports. Place the methods aside, not inside.

package net.sourceforge.subsonic.controller;

import java.io.IOException;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.mail.*;
import javax.mail.internet.*;

public class ContactServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
	
		
	String email = request.getParameter("email");
	String subject = request.getParameter("subject");
	String message = request.getParameter("message");
		
	if (email.isEmpty()){
		request.setAttribute("err_email", "Please proivde a email");
	}
	if (!test(email)){
		request.setAttribute("err_email", "Provided incorrect email");
	}
	if (message.isEmpty()){
		request.setAttribute("err_msg", "Please provide a message");
	}
	if (subject.isEmpty()){
		request.setAttribute("err_sub", "Please provide a subject");
	}
	
		
		if(!email.isEmpty() && !message.isEmpty() && !subject.isEmpty()){
			Properties props = new Properties();
			props.put("mail.smtp.host", "mysmptserver.com");
			props.put("mail.smtp.port", "587");
			
	        	Session session = Session.getDefaultInstance(props, null);
			
		try {
	                Message m = new MimeMessage(session);
	                m.setFrom(new InternetAddress(email, ""));
	                m.addRecipient(Message.RecipientType.TO, new InternetAddress("myadress@mydomain.com", ""));
	                m.setSubject(subject);
	                m.setText(message);
	                Transport.send(m);

	        } catch (AddressException e) {
	        	e.printStackTrace();
	        } catch (javax.mail.MessagingException e) {
		        e.printStackTrace();
		}
	        
		RequestDispatcher view = request.getRequestDispatcher("donate.view");
			
		view.forward(request, response);
		
			}else{
		RequestDispatcher view = request.getRequestDispatcher("help.view");
			
		view.forward(request, response);
			
			

		}
	}
	public static boolean test(String str){
		String reg = "[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})";
		Pattern p = Pattern.compile(reg);
		Matcher m = p.matcher(str);
		while(m.find())
		{
			String s1 = m.group(0);
			if (str == s1) return true;
		}

		return false;
	}

}
martin5211 37 Posting Whiz in Training

I forgot the i letter on line 8. Place that method after doGet. Use the following conditional after email.isEmpty() condition.

if (!test(email)){
		request.setAttribute("err_email", "Provided incorrect email");
	}
martin5211 37 Posting Whiz in Training

Here is the example, use it into a conditional. I extracted the pattern from http://www.mkyong.com/regular-expressions/how-to-validate-email-address-with-regular-expression/

public static boolean test(String str){
		String reg = "[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})";
		Pattern p = Pattern.compile(reg);
		Matcher m = p.matcher(str);
		while(m.find())
		{
			String s1 = m.group(0);
			if (str == s1) return true;
		}

		return false;
	}
martin5211 37 Posting Whiz in Training

That's more difficult, you need a static method that does an email extraction using regular expressions (Regex) and return a boolean.

Just another suggestion, you can also store the values of each field on request parameters and pass it to each input field to remember the content.

martin5211 37 Posting Whiz in Training

There is an extra parenthesis on message.isEmpty() call.

if(!email.isEmpty() && !message.isEmpty()) && !subject.isEmpty()){
martin5211 37 Posting Whiz in Training

Could you be more specific? Are you using out.println(request.getAttribute("err_msg")) on the contact form?

martin5211 37 Posting Whiz in Training

Both are almost the same code...

String email = request.getParameter("email");
	String subject = request.getParameter("subject");
	String message = request.getParameter("message");
		
	if (email.isEmpty()){
		request.setAttribute("err_email", "Email is empty");
	}
	if (message.isEmpty()){
		request.setAttribute("err_msg", "Message is empty");
	}

	if(!email.isEmpty() && !message.isEmpty()){
	...
	}else{
		RequestDispatcher view = request.getRequestDispatcher("contact.jsp");
			
		view.forward(request, response);
			
	}
martin5211 37 Posting Whiz in Training

Well, we're validating if the message is null. It's possible to add more fields on that condition and an else clause to redirect to the form again. Also, would be nice to pass a request parameter to the jsp.

import java.io.IOException;
import java.util.Properties;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.mail.*;
import javax.mail.internet.*;

public class ContactServlet extends HttpServlet {

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
		
		String email = request.getParameter("email");
		String subject = request.getParameter("subject");
		String message = request.getParameter("message");
		
		if(!message.isEmpty()){
			String host = "smtp.gmail.com";
	    		int port = 587;
	    		String username = "*** your Gmail username ***";
	    		String password = "*** your Gmail password ***";
	    	
			Properties props = new Properties();
			props.put("mail.smtp.auth", "true");
	    		props.put("mail.smtp.starttls.enable", "true");
	        	Session session = Session.getDefaultInstance(props, null);
			
	        	String body = message;
	        
			try {
	         		Message m = new MimeMessage(session);
	       			m.setFrom(new InternetAddress(email, null));
	        		m.addRecipient(Message.RecipientType.TO, new InternetAddress("destination@example.com", "me"));
	        		m.setSubject(subject);
	          		m.setText(body);
	            
	          		Transport transport = session.getTransport("smtp");
	    	  		transport.connect(host, port, username, password);
	     
	    	 		Transport.send(m);

	        	} catch (AddressException e) {
	        		e.printStackTrace();
	        	} catch (javax.mail.MessagingException e) {
				e.printStackTrace();
			}
	        
			RequestDispatcher view = request.getRequestDispatcher("success.jsp");
			view.forward(request, response);

		}else{
			request.setAttribute("error", "Message is empty");
			
			RequestDispatcher view = request.getRequestDispatcher("contact.jsp");  // return to contact form
			view.forward(request, response);
			
		}
	}

}

Use out.println(request.getAttribute("error")) on the contact form to show the error. A better alternative would be:

<p>Mail message: <textarea name="message"></textarea>
<% if (request.getAttribute("error") != null) out.println(request.getAttribute("error")); %></p>
martin5211 37 Posting Whiz in Training

Another alternative, is to use Gmail as mail transport agent, with some modifications of the code:

import java.io.IOException;
import java.util.Properties;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.mail.*;
import javax.mail.internet.*;

public class ContactServlet extends HttpServlet {

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
		
		String email = request.getParameter("email");
		String subject = request.getParameter("subject");
		String message = request.getParameter("message");
		
		if(!message.equals(null)){
			String host = "smtp.gmail.com";
	    	int port = 587;
	    	String username = "*** your Gmail username ***";
	    	String password = "*** your Gmail password ***";
	    	
			Properties props = new Properties();
			props.put("mail.smtp.auth", "true");
	    	props.put("mail.smtp.starttls.enable", "true");
	        Session session = Session.getDefaultInstance(props, null);
			
	        String body = message;
	        
		try {
	        	Message m = new MimeMessage(session);
	        	m.setFrom(new InternetAddress(email, null));
	        	m.addRecipient(Message.RecipientType.TO, new InternetAddress("destination@example.com", "me"));
	        	m.setSubject(subject);
	        	m.setText(body);
	            
	        	Transport transport = session.getTransport("smtp");
	    		transport.connect(host, port, username, password);
	     
	    		Transport.send(m);

	        } catch (AddressException e) {
	        	e.printStackTrace();
	        } catch (javax.mail.MessagingException e) {
				e.printStackTrace();
			}
	        
			RequestDispatcher view = request.getRequestDispatcher("success.jsp");
			
			view.forward(request, response);

		}
	}

}
martin5211 37 Posting Whiz in Training

Yes, a SMTP server is missing according to the first line.

martin5211 37 Posting Whiz in Training

Can you give the complete stack trace of the error?

martin5211 37 Posting Whiz in Training

That's weird, works flawlessly in my computer. In most cases, you need to configure Postfix or Sendmail to accept incoming email through port 25.

martin5211 37 Posting Whiz in Training

Use String message = request.getParameter("message"); on the servlet to extract each input field value, the following snippet will do the rest:

import java.io.IOException;
import java.util.Properties;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.mail.*;
import javax.mail.internet.*;

public class ContactServlet extends HttpServlet {

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
		
		String email = request.getParameter("email");
		String subject = request.getParameter("subject");
		String message = request.getParameter("message");
		
		if(!message.equals(null)){
			Properties props = new Properties();
	        	Session session = Session.getDefaultInstance(props, null);
			
		try {
	                Message m = new MimeMessage(session);
	                m.setFrom(new InternetAddress(email, "user"));
	                m.addRecipient(Message.RecipientType.TO, new InternetAddress("dest@example.com", "me"));
	                m.setSubject(subject);
	                m.setText(message);
	                Transport.send(m);

	        } catch (AddressException e) {
	        	e.printStackTrace();
	        } catch (javax.mail.MessagingException e) {
		        e.printStackTrace();
		}
	        
		RequestDispatcher view = request.getRequestDispatcher("success.jsp");
			
		view.forward(request, response);

		}
	}

}
martin5211 37 Posting Whiz in Training

It's a common mistake that everyone makes. Other issue that could happen are related with thread safety when using attributes, could get the exact same symptoms.

martin5211 37 Posting Whiz in Training

Have you tried accBalance as instance or class variable?

martin5211 37 Posting Whiz in Training
echo empty($row['ProductPrice']) ? "FREE" : $row['ProductPrice'];
	echo "</td><td>"
martin5211 37 Posting Whiz in Training

This conditional, if $row is null or empty, the text "free" will always be displayed.

martin5211 37 Posting Whiz in Training

The code segment seems correct. Are you tried with empty() instead of is_null()?

martin5211 37 Posting Whiz in Training

Is this what you're looking?

SELECT * 
FROM 
`teams_types` 
JOIN  `teams` ON teams_types.team = teams.id
JOIN `product_types` ON teams_types.product_type = product_types.id
martin5211 37 Posting Whiz in Training

Paste the code at end, outside from the last conditional that checks $progyear variable.

Test the MySQL query directly from phpMyAdmin 'SQL' sheet if returns any result from your tables... I'm using yearid and exampapers fields with coincidental values, that's crucial to make a query on multiple tables. Maybe your field is courseyeartable.courseid. Modify it according to your requirements.

martin5211 37 Posting Whiz in Training

Use a SELECT...JOIN query to get results from related tables e.g.

SELECT * FROM courseyeartable JOIN elements ON (yearid = exampapers) WHERE courseid = $programme

I have seen an error in your code, $subjectname is a string, so checking for numeric value will always get FALSE. (look at the top of your source code where are assigned the $_GET array to simple variables).

This is the final code, try to customize it for your needs:

echo "<br /><br />";
if($subjectname != null && is_string($_GET["subjectname"]) && $programme != null)
{
	$sql = "SELECT * FROM courseyeartable  JOIN elements ON (courseyeartable.yearid = elements.exampapers) WHERE elements.subject = '".$subjectname."'";

	$result = mysql_query($sql,$conn);

	while($row = mysql_fetch_array($result))
	{
		echo $row['course_year'].' '.$row['subject']."<br />";
	}
}

This example shows course_year column from courseyeartable and subject from elements, you can use more fields.

martin5211 37 Posting Whiz in Training

Misticles, please try to make a more precision or give more details what do you want to perform. I mean, the code is working right, I can't see what is your real issue.

You're performing only two queries in the code, one for the second drop-down and the other for the last one. Maybe, you want to perform a query with the data selected from both tables joined, is that what you want to do?

martin5211 37 Posting Whiz in Training

I can't replicate your issue without the structure of your tables.

I'm testing your code here, seems to be working right with these tables

SET NAMES utf8;
SET FOREIGN_KEY_CHECKS = 0;

DROP TABLE IF EXISTS `elements`;

CREATE TABLE `elements` (
  `exampapers` text NOT NULL,
  `subject` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

insert into `elements` values('1','tom'),
 ('2','tom'),
 ('1','svenson'),
 ('1','taylor');

SET FOREIGN_KEY_CHECKS = 1;

and

SET NAMES utf8;
SET FOREIGN_KEY_CHECKS = 0;

DROP TABLE IF EXISTS `courseyeartable`;

CREATE TABLE `courseyeartable` (
  `yearid` int(11) NOT NULL AUTO_INCREMENT,
  `courseid` int(11) NOT NULL,
  `course_year` int(11) NOT NULL,
  PRIMARY KEY (`yearid`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

insert into `courseyeartable` values('1','1','2008'),
 ('2','2','2009');

SET FOREIGN_KEY_CHECKS = 1;

Testing server:

http://novo.ath.cx/d.php

martin5211 37 Posting Whiz in Training

Could you show me the error displayed? I can't find a syntax error in your code... the error seems to be located on the course year selection, subjects drop down appears to be filtered ok.

martin5211 37 Posting Whiz in Training

I'm looking at your code, the method used in your form and mysql variables is ok, but into the form code, the survey code is commented into <!-- ... --> tags, remove it.

Add value="<?php echo $_GET['center']?>" into the input tags, should be something like:

<input type="text" maxlength="2" size="3" name="center" value="<?php echo $_GET['center']?>" />-<input type="text" name="custID" maxlength="5" size="10" value="<?php echo $_GET['custID']?>" />

Now, you can use /pre_venture.php?center=10&custID=1 in your link

If you want to hide that input elements, use this instead of above code:

<input type="hidden" name="center" value="<?php echo $_GET['center']?>" />
<input type="hidden" name="custID" value="<?php echo $_GET['custID']?>" />

On the PHP submission code, you use only $_POST instead of $_POST['center'] on the first value. Is that ok?

JRSofty commented: Good post. You could have also mentioned the use of the $_REQUEST since she is mixing both $_POST and $_GET usage in her page. +2
martin5211 37 Posting Whiz in Training

Try $_GET instead of $_POST to get parameters every time you use URL method.

Also, try to remove the single quotes on the SQL query. Use it on the array index.

$sql= sprintf("INSERT INTO pre_vent (center, custID, yStart, yAcquired, yOther, comments)
VALUES
('%s','%s', ... )", 
   mysql_real_escape_string($_GET['center']),
   mysql_real_escape_string($_GET['custID']),
... );
martin5211 37 Posting Whiz in Training

I wrote a solution on your previous thread (http://www.daniweb.com/forums/thread186448.html)... this is almost a duplicated one. Why not to continue to develop your issue into your previous thread ?

martin5211 37 Posting Whiz in Training

Hi,

I'm returning to this forum from long time ago... Looking at this issue it isn't difficult at all... just dealing a bit with regular expressions, preg_match_all() should be the function that is worth to use e.g.
to store all links into an array:

$pattern = "/href=\x22([^\x22]*)\x22/";
preg_match_all($pattern, $string, $links);

Then, would be cool to take away javascript stuff from links, populating a new array e.g.

foreach($links[1] as $link){
	if(strpos($link, "javascript") === FALSE){
		$filtered_links[] = $link;
	}	
}

Little tuning would be necessary on the search pattern to extract the names on another array and use of mysql_query() to insert the arrays into a database.

martin5211 37 Posting Whiz in Training

I'm using the php executable from Terminal to load the php-gtk code (located in /usr/local/php-gtk in my Mac OS 10.5 after installing this DMG package).

Before compiling the code you can perform php -l code_example.php to check for syntax errors (maybe, we can do it automatically from the editor assigning a macro or menu function). In Windows should work exactly as described here, also it's possible to perform and interpret the code, showing errors and output messages on the MS-DOS prompt using directly php code_example.php alone without -l parameter.

martin5211 37 Posting Whiz in Training

I've fixed your code:

<?php 

if (!class_exists('gtk')) {
    die("Please load the php-gtk2 module in your php.ini\r\n");
}

function pressed()
{
    echo "Hello again - The button was pressed!\n";
}

function pressed2()
{
    echo "Hello again - The button was pressed!\n";
}

 
$window = new GtkWindow();

$window->resize(800,600);
$window->set_title('My Diary');
$window->connect_simple('destroy', array('Gtk', 'main_quit'));


$button1 = new GtkButton('Jan');
$button1->connect_simple('clicked', 'pressed');
$button1parrent = new GtkAlignment(0, 0, 0.01, 0.01);
$button1parrent->add($button1);



$button2 = new GtkButton('February');
$button2->connect_simple('clicked', 'pressed2');
$button2parrent = new GtkAlignment(0, 0, 0.01, 0.01);
$button2parrent->add($button2);


$buttonbox = new GtkVButtonBox();    // or GtkHButtonBox for horizontal placement
$buttonbox->add($button1parrent);
$buttonbox->add($button2parrent);


$window->add($buttonbox);

$window->show_all();
//$window->set_resizable(false);
Gtk::main();
 

?>

I'm learning php-gtk too :) It seems like is mandatory to enclose UI elements into boxes before adding to GtkWindow.

I recommend to read this serie of tutorials:

http://gtk.php.net/manual/en/tutorials.packing.php

martin5211 37 Posting Whiz in Training

There is a little mistake, on your code you're using a comparing operator (double equal signs) instead of assignation (one equal sign). Try with this example:

<?php 

$a = 20;
$a = $a + (-10);

echo $a;

?>

It's the same:

<?php 

$a = 20;
$a += (-10);

echo $a;

?>
martin5211 37 Posting Whiz in Training

I don't undertand the meaning of your question... Why not to use an incrementing/decrementing operators (e.g. $updown--) or assignment operator. The values inside the braces doesn't contain an assignment operator, so doesn't change their value when the condition is true.

martin5211 37 Posting Whiz in Training

PHP.net the best reference :-)

Regards

martin5211 37 Posting Whiz in Training

I've added the source at code snippets, using HTML message format at this time.