This is the error i get form my error_log on my server online

PHP Warning:  implode() [<a href='function.implode'>function.implode</a>]: Invalid arguments passed in /home1/zxx/public_html/admin/userindex/sms/sms.php on line 127

i looked in all of the code but can't find why that error.

Here is the code, it's an sms app writing in php.

        <?php

                $smsghurl="http://api.smsgh.com/v2/messages/send";
                $smsghuname="xxx";
                $smsghpass="xxx";
                $shortcode="xxx";               



    //select total number of subscribers  
    $query1 = "SELECT count(phone) FROM contacts";
    $fones = mysql_query($query1);
    $num = mysql_result($fones,0,0);

    //select every thing from diction
    $query = "SELECT * FROM diction WHERE status='unsent' LIMIT 1";
    $sql = mysql_query($query);
    $total = mysql_num_rows($sql);
    $result = mysql_fetch_array($sql);
    $val = $result['id'];
    $msg = $result['msg'];

    $pos = 1;
    while($num !=0)
    {
        $squery = "SELECT * FROM contacts WHERE id=$pos";
        $sall = mysql_query($squery);
        $stotal = mysql_num_rows($sall);
        $sresult = mysql_fetch_array($sall);
        $phone_no = $sresult['phone'];
        $smsg = str_replace("+","00",$phone_no);
        $pos++;
        $num--;
        $txt=urlencode($msg);

        $send= "http://api.smsgh.com/v2/messages/send?username=xxx&password=xxx&from=xxx&to=$phone_no&text=$txt&id=client1";
        $final=implode("",file($send));
    }

    //set sent info as unsent
    $query2 = "UPDATE diction SET status ='sent' WHERE id='$val'";
    $result2 = mysql_query($query2) or die ("Error! No information available".mysql_error());   


                // Get details form user

    $sendfrm =strtolower($_REQUEST['text']);
    $phone_no =$_REQUEST['to'];
    $shortcode =$_REQUEST['from'];
    $when =$_REQUEST['date'];

    if($sendfrm == 'med')
    {
        $sql = "INSERT INTO contacts(phone, status, register) VALUES ('$phone_no','unsent', '$when')";
        mysql_query($sql) or die(mysql_error);

        $submgs = "Thank you for subscribing to xxx,to unsubscribe txt hstop to xxx";

        $txt=urlencode($submgs);

        $send= "http://api.smsgh.com/v2/messages/send?username=xxx&password=xxx&from=xxx&to=$phone_no&text=$txt&id=client1";
        $final=implode("",file($send));
    }

        if($sendfrm == 'hstop')
                {
            $query = "UPDATE contacts SET status ='stop' WHERE phone=$phone_no";
            $result2 = mysql_query($query) or die ("Unsubcription failed".mysql_error());

$unsub= "Thank you for your time with xxx,to subscribe at any time txt xxx to xxx";

$txt=urlencode($unsub);

        $send= "http://api.smsgh.com/v2/messages/send?username=xxx&password=xxx&from=xxx&to=$phone_no&text=$txt&id=client1";
        $final=implode("",file($send));
    }
?>
Member Avatar for diafol

Kinda works for me:

$send = "http://www.example.com";
$final=implode("",file($send));
echo $final;

When I replace example.com with my own remote website it's fine. But do you have 'allow_url_fopen' as 'On' under Core when you phpinfo(); ?

I think that needs to be On to access remote files. If not, you may have to use cURL.

If it is on - check your url. Print it out to the screen first and then copy it and then paste it into the address bar to see if it gives you what you need / takes you where you thought.

echo $send;
exit;

I think file($send) is not returning anything, hence the error (it is apparently not an array). It's quite possible you're not allowed to do that. If you are on a shared host, file() is often blocked. You may need to switch to cUrl.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.