ArgumentCountError: Too Few Arguments


Recently, I was tasked with migrating one of our applications from using a MySQL backend for our custom code to utilizing SQL for numerous reasons. Not really a big deal, I’ve figured out most of the errors I’ve been getting - except for this last one.

**Fatal error** : Uncaught ArgumentCountError: Too few arguments to function linkAccount(), 4 passed in functions.php on line 43 and exactly 5 expected in functions.php:205

Line 30-45:

 case 'loadIndiv':
         //check database for entry in users_providers and add if absent
          //replaces db_add_user.tmpl
          //need to have subUID 
		  echo 'full-string' . $data['subUID'];
		  echo $uid;
          db_add_user($data['preferred_username'], $provider, $uid, $data);
          //loop through loaded data and linkAccount for each
          foreach($data as $row){

The function linkAccount is below:

function linkAccount($account,$sub,$provider,$email,$conf) {
    $whmapiuser = $conf['root']['whmapiuser'];
    $whmapitoken= $conf['root']['whmapitoken']; 
    $thisserver = $conf['server']['thisserver'];
	$query = "https://" . $thisserver . ":2087/json-api/link_user_authn_provider?api.version=1&username=$account&provider_id=$provider&subject_unique_identifier=$sub&preferred_username=$email&service_name=cpaneld";
    echo $query;
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
    $header[0] = "Authorization: whm $whmapiuser:$whmapitoken";
    curl_setopt($curl, CURLOPT_URL, $query);
  $result = curl_exec($curl);

    $http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
	if ($http_status != 200) {
 	echo "[!] Error: " . $http_status . " returned\n";
    } else {
        $json = json_decode($result);
        if($json->metadata->result || strpos( $json->metadata->reason,"whostmgr")){
    return $ret;


I understand that it is erroring on the $conf variable that is there, but that is required for the whmapi tokens and stuff that you’ll see below that… however, it won’t get past this error. The code is exactly the same from when I migrated it from MySQL to SQL and I don’t understand why it is erroring out and I’m hoping someone on here might.


You did not provide the $conf variable.

I can’t see how it can be - the function definition has five parameters, and the call to it does not. As you use parts of the $conf array in your function, what values would you have expected the code to use prior to making these changes, if you don’t send them?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.