PHP - Calling function inside another class -> function
<p>I'm trying to do this: </p>

<pre><code>class database {    
function editProvider($post)
{   
    $sql = "UPDATE tbl SET ";
        foreach($post as $key =&gt; $val):
            if($key != "providerId")
            {
                $val = formValidate($val);
                $sqlE[] = "`$key`='$val'"; 
            }
        endforeach;

    $sqlE = implode(",", $sqlE);

    $where = ' WHERE `id` = \''.$post['id'].'\'';
    $sql = $sql . $sqlE . $where;

    $query = mysql_query($sql);

    if($query){
        return true;
    }
}
//
}//end class
</code></pre>

<p>And then use this function <strong>* INSIDE of another class *</strong>: </p>

<pre><code>function formValidate($string){
  $string = trim($string);
  $string = mysql_real_escape_string($string);
  return $string;
}
//
</code></pre>

<p>.. on $val. Why doesn't this work? if I write  in a field of the form, it's not escaping anything at all. How can that be? </p>

<p><strong>* UPDATE *</strong>
handler.php:</p>

<pre><code>if(isset($_GET['do'])){

if($_GET['do'] == "addLogin")
{
    $addLogin = $db-&gt;addLogin($_POST);
}

if($_GET['do'] == "addProvider")
{
    $addProvider = $db-&gt;addProvider($_POST);
}

if($_GET['do'] == "editProfile")
{
    $editProfile = $db-&gt;editProfile($_POST);
}

if($_GET['do'] == "editProvider")
{
    $editProvider = $db-&gt;editProvider($_POST);
}
}
//end if isset get do
</code></pre>

<p>** The editProvider function works fine except for this :-) ** </p>
