我有一個從mysql表中收集數據的while循環,將它們插入到php變量中。這些php變量作爲參數傳遞給php函數中存在的url。顯然,url不會選擇php變量的值。需要幫助。代碼看起來像這樣。如何在一個url中傳遞php變量,存在於php函數中
<?php
include('adodb/adodb.inc.php');
$link=mysql_connect("160.60.20.100","vcpm","abcd");
mysql_select_db("vcpm");
$GMT='2017-04-23 00:59';
$MinusOne='2017-04-23 00:00';
$query="SELECT fraud_id,stat_id from Hasoffers where fraud_id IS NOT NULL AND stat_datetime between '".$MinusOne."' AND '".$GMT."';";
$pl=mysql_query($query);
$count=mysql_num_rows($pl);
while($row=mysql_fetch_array($pl))
{
$conversion_id=$row['stat_id'];
$fraud_category=$row['fraud_id'];
echo ip($conversion_id,$fraud_category).PHP_EOL;
}
function ip($conversion_id,$fraud_category)
{
$conversion_id= $argv[1];
$fraud_category= $argv[2];
$url="https://api.hasoffers.com/Apiv3/json?NetworkId=mxpresso&Target=Conversion&Method=updateMeta&NetworkToken=NETY5hP42BJX8KJlTmTQfsjTo1Rq1m&id=".$conversion_id."&data[note]=".$fraud_category;
echo $url;
// Initiate curl
$ch = curl_init();
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
//Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
// Set the url
curl_setopt($ch, CURLOPT_URL,$url);
// Execute
$result=curl_exec($ch);
// Closing
curl_close($ch);
}
?>
你可以分享你所得到的錯誤傳遞argumnents PHP腳本 $ argv的使用? –
$ conversion_id = $ argv [1]; $ fraud_category = $ argv [2]; 這些是什麼? 您可以通過名稱直接在函數內部使用參數 –
將它們作爲參數在url中傳遞 –