Jump to content

Recommended Posts

Hello i am trying to set a $_GET as a constant variable in a class to use in a few different methods in parent and child classes.

 

This $_GET will be used to create a dynamic title using the URL and a few other things like page titles etc.

 

The problem is i am not sure if i am allowed to do this or how it works as i am getting the following error:

 

Parse error: syntax error, unexpected T_PUBLIC in /home/zqyrdetv/public_html/business_class.php on line 12

 

this is the code i am using:

 

class business{

public $businesstype = $_GET['business'];
public $region;
public $businessname;
private $con;

function title()
{
//$business = $_GET['business'];
$title = "Music & Media Business | UK $businesstype";
echo "$title";
}

function database_connect()
{
$con = mysql_connect("localhost","*****","*****") or die ('Unable to connect to database!');
mysql_select_db("zqyrdetv_clientinfo", $con) or die ('Cannot find database!');
}

function database_disconnect()
{
mysql_close($con);
}
}

 

You have to initialize variables in your constructor.

 

<?php
class business{

public $businesstype;
public $region;
public $businessname;
private $con;

public function __construct() {
    $this->businesstype = $_GET['business'];
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.