Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6166237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:18:13+00:00 2026-05-23T22:18:13+00:00

I am getting this error on the following code, and cant figure out why.

  • 0

I am getting this error on the following code, and cant figure out why. I think it is looping through each $call twice, but I dont know why. Anyone care to give me a hand proofreading?

PHP Notice: Undefined index: call in /var/www/swvx/timedcdr2.php on line 72

Thanks!

<?
//to be polled every 30 seconds.  should first get a list of accoutn IDs, then use them to get the CDR for the last day.
//include switchvox libraries
require_once("SwitchvoxRequest.php");

//define sql connection stuff
$db_host = "host";
$db_user = "user";
$db_pass = "secret";
$db = "db";
$table_sr = "tblSalesReps";
$table_cd = "tblCallsMadeReceived_raw";
$link = mssql_connect($db_host, $db_user, $db_pass);

//make sure we can connect
if (!$link || !mssql_select_db($db, $link)) {
        die('Unable to connect or select database!');
        }

//define pbx connection stuff
$sv_host = "url";
$sv_user = "user";
$sv_pass = "secret";

//query the salesrep table to find the account IDs available
$acid_sql = "SELECT * FROM $table_sr WHERE [pbx_accountid] > 0";
$acid_res = mssql_query($acid_sql);

//get and format the time and date as YYYY-MM-DD, format the time as HH:MM:SS
$date = date('Y') . "-" . date('m') . "-" . date('d');
$time = date('H') . ":" . date('i') . ":" . date('s');

//take only the last hour of results, rather than an entire day
$st_time = date('H')-1 . ":" . date('i') . ":" . date('s');

echo "<pre>";

while ($row = mssql_fetch_array($acid_res, MSSQL_ASSOC)) {
        $req = new SwitchvoxRequest($sv_host, $sv_user, $sv_pass);
        $reqpar = array
                (
                'account_ids' => array
                        (
                        'account_id' => array
                                (
                                $row['pbx_accountid']
                                )
                        ),
                'start_date' => array
                        (
                        $date . " " . $st_time
                        ),
                'end_date' =>  array
                        (
                        $date . " " . $time
                        ),
                'sort_field' => array
                        (
                        ),
                'sort_order' => array
                        (
                        'DESC'
                        )
                );

        $res = $req -> send("switchvox.callLogs.search", $reqpar);
        $result = $res->getResult();
        $calls = $result['calls']['total_items'];
        print_r($calls);
        print_r($row['pbx_accountid']);
        echo "<br><br>";
        if($result['calls']['call']) {   //<====LINE 72 ################################
                foreach($result['calls']['call'] as $call) {
                        $id = $call['id'];
                        //check to see if the call has already been logged
                        $id_sql = "SELECT * FROM $table_cd WHERE callID='$id'";
                        $id_res = mssql_query($id_sql);
                        $exid = mssql_fetch_array($id_res, MSSQL_ASSOC);

                        if($exid['callID']) {
                                //print_r($exid);  //uncomment to show duplicate results
                                } elseif (!$exid['callID']) {
                                        //print_r($call);  //uncomment to show new results
                                        //varialbes to insert
                                        $from = $call['from_number'];
                                        $to = $call['to_number'];
                                        $durat = $call['talk_duration'];
                                        $start = $call['start_time'];
                                        $callid = $call['id'];
                                        $calltype = $call['origination'];
                                        //set the proper values into extension/phonenumber
                                        if($calltype == "outgoing") {
                                                $extension = $from;
                                                $phonenumber = $to;
                                                } else {
                                                        $extension = $to;
                                                        $phonenumber = $from;
                                                }
                                        //insert the data into the table
                                        $fi_sql = "INSERT INTO $table_cd (extension, phonenumber, calldatetime, duration, callID, calltype) VALUES ($extension, $phonenumber, '$start', '$durat', '$callid', '$calltype')";
                                        $fi_res = mssql_query($fi_sql);
                                                }
                                }
                }
}
?>

edit-
It does work; it just throws that error once in a while. At least I tihnk it works. I assume that it maybe gets to the last result of the pbx_accountid array and theres no more? I am going to count the number of times it goes, and see if it corresponds.

edit-
yes, there are 20 occurences of the error every time it’s run, and there are 20 account IDs. How do I force it to stop if there are no more call indexes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:18:14+00:00Added an answer on May 23, 2026 at 10:18 pm

    Change this

    if($result['calls']['call']) {   //<====LINE 72 ################################
    

    To this

    if(isset($result['calls']['call'])) {   //<====LINE 72 ################################
    

    That notice means you’re reading a variable which doesn’t exist. You’re doing so to check if the variable exists. There’s a function to check if a variable exists without trying to read it, isset.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting this error, and cant figure out what the issue is. Server
I am getting this error on a remote server, but the same code executes
Getting Expected ',' or '{' but found '#44559' error. My code looks like this:
This is a common error, I'm sure, but I can't figure out why I'm
I am getting the following errors but can't figure out why.. Msg 16915, Level
I am getting this error but only very occasionally. 99.9% of the time it
I'm getting this error on a compact framework form. code generation for property 'inputControl'
I am getting the following error message on the code below (which is at
I am getting the following error from my code: Attempt to split long or
Anyone getting this error when using the new free chart controls MS bought from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.