Click here to Skip to main content
15,890,043 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Parse error: syntax error, unexpected 'else' (T_ELSE) in C:\xampp\htdocs\OOP\blog\libs\database.php on line 33


What I have tried:

PHP
<pre><?php


class database{

public $host = DB_HOST;
public $user = DB_USER;
public $pass = DB_PASS;
public $db_name = DB_NAME;

 public $link;

public function __construct(){
	$this->connect();
}


 private function connect(){
$this ->link=new mysql ($this->host,$this->user,$this->pass,$this->db_name);



 }

public function select($query){

$result = $this->link ->query($query);
if($result->num_rows> 0){
}
return $result;


else{
	return false;
}


}
public function insert($query){

$insert = $this->link->query($query);

if($insert){
	header('location:index.php?insert= Post inserted ...');
}
else{
	echo"Post did not insert ...";
}

}

public function update($query){

$update = $this->link->query($query);

if($update){
	header('location:index.php?Update= Post updated  ...');
}
else{
	echo"Post did not update ...";
}

}

public function delete($delete){

$delete = $this->link->query($query);

if($delete){
	header('location:index.php?delete= Post deleted ...');
}
else{
	echo"Post did not delete ...";
}

}


}

?>
Posted
Updated 14-Sep-17 7:45am

1 solution

Quote:
if($result->num_rows> 0){
}
return $result;


else{
return false;
}
The above code is wrong. You probably meant
PHP
if($result->num_rows> 0){
  return $result;
} 
else{
  return false;
}
 
Share this answer
 
Comments
ALEX8998 14-Sep-17 13:49pm    
Wow,problem has fixed.Thank u !
CPallini 14-Sep-17 14:13pm    
You are welcome.
Patrice T 14-Sep-17 15:35pm    
Accept the solution as it solved the problem.
It will close the question and reward the author of solution.

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