Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
PHP
<?php

class article{
	
private $row;

public function __construct(){

require_once('connection.php'); 
mysql_select_db($db, $test);	

$query = "SELECT * FROM articles WHERE path = $_SESSION['path']";
$result = mysql_query($query, $test) or die(mysql_error());
$this->row = mysql_fetch_array($result);


}

public function process($field) {

if($field == 'tool'){
echo $this->row['path'];
}
else if($field == 'test'){
echo $this->row['title'];
}
 

}


}

$obj = new article();
$obj->process('tool');
$obj = new article();
$obj1->process('test');

?>


How to run the process method twice in this scenario? It just run once and execution stops.
Posted

1 solution

Check
PHP
$obj = new article();
$obj->process('tool');
$obj = new article();
$obj1->process('test');


$obj1 not initialized. Hope this helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900