我有一个从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中传递 –