用于php IP Bindings的Mikrotik api

so i have this code

<?php
require('routeros_api.class.php');
include 'include/global.php';
include 'include/function.php';

$username = $_GET['user'];

$sql    = "SELECT user_macaddress FROM demo_user WHERE user_name='".$username."'";
$result1    = mysql_query($sql);
$mac        = mysql_fetch_array($result1);

$API = new RouterosAPI();

$API->debug = true;

if ($API->connect('192.168.88.1', 'admin', '1')) {

    $API->write('/ip/hotspot/ip-binding/add',false);
    $API->write('=type=bypassed',false);
    $API->write("=mac-address='".$mac."'",true);
    $READ = $API->read();
    $API->disconnect();
    ob_clean();
    header("location:http://google.com");

}


?>

i use the php api for mikrotik for add the mac address automatically, but the mac address never shown in my ip bindings in winbox. can u guys help me with this?

Do not wrap MAC address to the single quotation marks. Use this code:

$API->write('/ip/hotspot/ip-binding/add',false);
$API->write('=type=bypassed',false);
$API->write('=mac-address='.$mac,true);

MAC can be in the following formats: xx:xx:xx:xx:xx:xx or xxxxxxxxxxxx.