title: using functions to query mysql database in php
body: <p>This is one thing I can't understand. I'm using a function which fetches records from the database. And if that record doesn't exist. It performs an insert query. I even echoed out to ensure that those 2 parameters contains something. And it really contain something. What I can't understand is that it doesn't perform the insert query. 
  I also tested the insert query below on another script which doesn't use function. And it worked.</p>
  
  <pre><code>function fetch_customer($cust, $credit){
  
  $getcnum=query_database("SELECT Cust_Name, CUSID FROM customer_credit WHERE Cust_Name='$cust'","onstor",$link);
  
  if(mysql_num_rows($getcnum)==0){
      $fullname=explode(",", $cust);
      $lname= $fullname[0];
      $fname= $fullname[1];
  
  
      query_database("INSERT INTO customer_credit(Cust_Name, CREDIT) VALUES('$cust','$credit')",'onstor' ,$link);
  
      echo "customer: ".$cust."&lt;br/&gt;";
  
      echo "credit: ".$credit;
      query_database("INSERT INTO customer_table(CLNAME, CFNAME) VALUES('$lname', '$fname')",'onstor',$link);
  
  }
  </code></pre>
  
  <p>Then I would call the function later on. </p>
  
  <pre><code>fetch_customer($customer, $custcred);
  </code></pre>
  
  <p>Where do I start if I want to debug this one?</p>