0

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

4
  • 1
    mysql_* fuctions are deprecated. Use mysqli. Commented May 22, 2013 at 21:55
  • what does the error message say specifically? qué dice el mensaje de error? Commented May 22, 2013 at 21:56
  • Do you mean there is a syntax error on line 10 or that the query function is returning false and the die() statement is running? Commented May 22, 2013 at 21:56
  • Why don't you actually echo out the mysql error message to find out what is going wrong? Commented May 22, 2013 at 21:56

1 Answer 1

2

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

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.