Log in

View Full Version : Help with validating a PHP script... "unexpected $end"


ngaming.net
10-06-2009, 09:00 AM
I'm no genius with PHP, this will probably be obvious to you at some point soon.

I've written a PHP script to perform a very specific function: find all users who have a session open on the site AND find if they have ticked a particular profile field as yes. I'm not really used to this (ColdFusion and .NET developer, the syntax is confusing me) so please help!

<?php

function get_onlinehosts($onlinehosts)
{
global $vbulletin;
$datecut = TIMENOW - $vbulletin->options['cookietimeout'];
$onlinehosts = $vbulletin->db->query_first("SELECT * FROM " . TABLE_PREFIX . "session

WHERE userid = $userinfo[userid] AND lastactivity > $datecut AND .userfield.field6 = 'yes'
INNER JOIN " . TABLE_PREFIX . "userfield ON(session.userid = userfield.userid));
{
return $onlinehosts;
}
}
?>

Lynne
10-06-2009, 02:00 PM
I can't think of why you have parenthesis around your return line and no need for the period at the beginning of ".userfield.field6"

ngaming.net
10-07-2009, 04:53 PM
Thanks Lynne, I'll take a look at it a little later.

1) I thought that there was supposed to be an affirmative action at the end of the function to describe how it was going to be output?

2) I don't quite know. There's a large space that opened up there, I don't know if that's even there intentionally.

Lynne
10-07-2009, 05:31 PM
1) You just want to have the return line - no need to put it in {}

2) Well, I don't know why either. :)