天天看點

php調用未定義的函數_php-調用類方法時出現“調用未定義函數”錯誤

這是錯誤Fatal error: Call to undefined function assign(

這是代碼,如您所見,我顯然已經定義了該函數,是以為什麼它不起作用

class shades {

function create($name, $shades, $slug, $shortDesc, $longDesc, $position){

$name = sanitize_paranoid_string($name);

$slug = slug($name);

$shortDesc = sanitize_sql_string($shortDesc);

$longDesc = sanitize_sql_string($longDesc);

$query = mysql_query("INSERT INTO products (type, name, slug, shortDesc, htmlDesc, position)VALUES('shades','$name','$slug','$shortDesc','$longDesc','$position')")or die(mysql_error());

$ID = mysql_insert_id();

assign($shades, $ID);

if($query) {return true;}

else {return false;};

}

function delassign($toID){

mysql_query("DELETE FROM assign WHERE type='shades' AND toID='$toID'")or die(mysql_error());

}

function assign($shades, $toID)

{

foreach($shades as $shade)

{

$result = mysql_query("INSERT INTO assign(type, typeID, toID)VALUES('shades','$shade','$toID')")or die(mysql_error());

if($result){echo "Added!";}

else{echo"Not Added!";}

};

}

}