Ok, Im a newbie to the PHP oop world.
I have this snippet of code that I have copied (or at leastt ried to) from a basic OOp file a friend sent to me. However I'm getting Parse errors??
This is the original script I used
class Hello {
var $text = "";
function say_hello() {
$this->text = "Hello Pablo!";
$this->text .= "<br />Hello Again!";
$this->text .= "<br /><a href='oop.php?a=source'>Show Source</a>";
echo $this->text;
}
function show_source() {
echo highlight_file('oop.php');
}
}
$hello = new Hello;
if (!isset($_GET['a'])) {
$_GET['a'] = 'hello';
}
switch($_GET['a']) {
case 'hello':
$hello->say_hello();
break;
case 'source':
$hello->show_source();
break;
default:
$hello->say_hello();
break;
}
?>
now this is my version. It is checking to see if there are errors when a user signs up.
<?php
class CreateUser {
function CheckUserDetails() {
//set error var
var $error = ""; ##This is line 14 that the parse error refers too.
//First check various elements, passwords birthday etc
//username
$query = "SELECT * FROM mcp_userinfo WHERE username='{$_POST['RegisterID']}'";
$result = mysql_query($query);
CheckMySQL();
$num=mysql_num_rows($result);
if ($num != 0){ $this->error = "<li>The username you requested has already been taken. Please choose another.<br>"; }
//email
$query = "SELECT * FROM mcp_userinfo WHERE email='{$_POST['Email']}'";
$result = mysql_query($query);
CheckMySQL();
$num=mysql_num_rows($result);
if ($num != 0){ $this->error .= "<li>Email already in use. you may only register one username per email.<br>";}
//passwords match?
if ($_POST['Password1'] != $_POST['Password2']) { $this->error .= "Your passwords do not match.<br>"; }
//accepted Terms and conditions?
}
}
$CreateUser = new CreateUser;
$CreateUser->CheckUserDetails();
?>
my parse error is this:
<b>Parse error: parse error, unexpected T_VAR in c:\program files\easyphp1-7
\www\mountaincanon\mcparty\Tools\JoinTheParty.php on line 14
</b>
Any help? Pleasedont bombard me with advanced OOPy sayings as I will most likely not know them!
cheers in advance