user1920626
user1920626

Reputation:

data structure in php and mysql

Hello I have error on line 10 could tell me what is my mistake. Is it a boolean problem? I tried various solutions but I still get the same error:

<?php

class classData {

    function __construct() {
        mysql_select_db("dbVentas", mysql_connect("localhost", "root", ""));
    }

    function voidInsert($code, $name) {
        if (validateCodigo($code) == true) {
            mysql_query("insert into tbZone (code,zone) values ('" . $code . "','" . $name . "')")
                    or die("ERROR!!!... ");
        }
    }

    function validateCodigo($code) {
        $ok = true;
        $isql = mysql_query("select * from tbZone where code='" . $code . "'");
        $cCod = 0;

        while ($oRow = mysql_fetch_array($isql)) {
            extract($oRow);
            $cCod++;
        }

        if ($cCod > 0) {
            $ok = false;
        }

        return $ok;
    }
}
?>

I call this php file DataClass.php

Upvotes: 0

Views: 65

Answers (1)

ilbesculpi
ilbesculpi

Reputation: 328

Since you're calling another class method, you should use

$this->validateCodigo($code) instead of validateCodigo($code)

Upvotes: 2

Related Questions