简体   繁体   中英

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM