Re: Class Syntax Help or Globals issue
| From: | Bob Pillford | Date: | Fri, 04 Jun 2004 07:17:24 +0000 |
| Subject: | Re: Class Syntax Help or Globals issue | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-187603@lists.php.net to get a copy of this message | ||
Thanks very much!
Marek Kilimajer wrote:
bob pilly wrote:Hi All I am new to classes and are trying to work out whether they will make my coding experience easier. I have written the following test class which is trying to take three variables from a mssql query and add them as variables in a new class. This isnt working as i keep getting an error that says ; Warning: Missing argument 1 for app() in /var/www/htdocs/temp3.php on line 13 Warning: Missing argument 2 for app() in /var/www/htdocs/temp3.php on line 13 Warning: Missing argument 3 for app() in /var/www/htdocs/temp3.php on line 13 the code ..... //a basic class to store basic appointment details in class App {This is the function's constructor, it's called when you create a class instance using "new" operator:var $name; var $the_date; var $result;//add values to the variablesSo instead of:function App($app1name,$appdate,$appresult){ $this->name=$app1name; $this->the_date=$appdate; $this->result=$appresult; }} $query="select app1name,appdate,appresult from appresult where appdate > 'jun 01 2004'"; $qresult=mssql_query($query,$numero);//get the number of rows returned $numrow=mssql_num_rows($qresult); if($row=mssql_fetch_array($qresult)){$i=0; do{ $j=$i;you have to suply the arguments to the contructor this way: $j= new App($row[app1name],$row['appdate'],$row['appresult']);$j= new App; $j->App($row[app1name],$row['appdate'],$row['appresult']);} while($row=mssql_fetch_array($qresult));} ?> Is there a syntax problem with the way im trying to pass the value of the $row array cells into the class function? I have looked at the online manual for classes but find it a bit confusing on how to input and extract variables data in classes. Any help or pointing in the direction of some good docs would be greatly appreciated! thanks for any help in advance.