dongwei8440 2011-05-18 10:28 采纳率: 100%
浏览 53
已采纳

检索存储在MySQL中的变量名并回显该值?

I am building a yql url for a script. I have made parts of the url variables and then just reconstructed them together. This is just in case anything changes then I can make an easy fix.

$cllrssformat gets the rss feeds that are in the yql url. I have replaced the search term with the variable $clsearch and stored that in mysql table. I was expecting that it would write the value of $clsearch, but it only shows $clsearch (literally).

This is an example of what I have stored in the mysql table.

'http://daytona".$clsearch."','http://keys".$clsearch."'

And this is the PHP code.

// link to yql
$yqlurl = 'http://query.yahooapis.com/v1/public/yql?q=';
// yql query
$yqlquery = 'select title,source,description,date from rss where url in ( ';
// cl search parameters
$clsearch = '.somesite.com/search/sss?query=blah+blah&srchType=T&minAsk=&maxAsk=&format=rss';
// yql sort paramaters
$yqlparams = ' ) | unique(field="source") | sort(field="date", descending="true")';
//  cl rss feeds formatted for yql
$clrssformat = mysql_query("SELECT url FROM be_yqlurls WHERE id='1'");
$temp = mysql_fetch_row($clrssformat);
$clrssformat = $temp[0];
// create the full url
$fullurl= $yqlurl.$yqlquery.$clrssformat.$yqlparams;
$fullurl = rawurlencode($fullurl);
echo rawurldecode($fullurl)
// echo '<br><br>'.$fullurl;

This is the output. Obviously needing the value of $clsearch vs. "$clsearch".

http://query.yahooapis.com/v1/public/yql?q=select title,source,description,date from rss where url in ( 'http://daytona".$clsearch."','http://keys".$clsearch."','http://fortlauderdale".$clsearch."','http://fortmyers".$clsearch."','http://gainesville".$clsearch."','http://cfl".$clsearch."' ) | unique(field="source") | sort(field="date", descending="true")

First real try with PHP so be easy. :) Thanks

  • 写回答

1条回答 默认 最新

  • drjv5597 2011-05-18 10:34
    关注

    If I understand the question correctly I think that what you need to do is:

    // create the full url
    $fullurl= str_replace('$clsearch', $clsearch, $yqlurl.$yqlquery.$clrssformat.$yqlparams);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮