For some reason, the else statement does not start, and I think for some reason my method does not return true.
main code
function msg($content) { //function that echos out page with content in it } $car=new yamiko_car; if(!$car->add())//returns bool false on fail and true on success {msg($car->error);} else{msg('Car has been added');}
and the method does not return false on failure, where I check the data, but just add a comment there. already tested everything and it worked fine.
public function add() { //gets data succesfully //MySQL $this->query("INSERT INTO car (year, make, model, price, obo, img1, img2, img3, img4, description) VALUES ('$year', '$make', '$model', '$price', '$obo', '$img1', '$img2', '$img3', '$img4', 'txt') "); echo 'mysql added'; return true; } function query($sql, $result=false) { $query=mysql_query($sql); if(!$query){$this->mysqlError.=mysql_error().'<br />';return false;} if($result==false){return true;} else{return $query;} }
I added an echo instruction and it fires ...
when there is an error, it returns false and runs msg()
I switched the operator to if($car->add()){msg('car added')}else{msg($car->error);} , if or else statements will not be run.
in addition, any code after the if statement does not run and no php or mysql errors occur.