I have class that outputs website rank
$urlInfo->getUrlInfo();
This is the alexa amazon aws for rank. the out would be rank of domain. I need to insert the rank into the db but i can't unless i set it to a variable.
what can I do?
i have tried:
mysql_query("INSERT INTO rank (date, domain, rank) VALUES ('$date','$domain','".$urlInfo->getUrlInfo()."')")
but rank is empty.
this is what the geturlinfo function looks like
public function getUrlInfo() {
$queryParams = $this->buildQueryParams();
$sig = $this->generateSignature($queryParams);
$url = 'http://' . self::$ServiceHost . '/?' . $queryParams .
'&Signature=' . $sig;
$ret = self::makeRequest($url);
//echo "
Results for " . $this->site .":
<br>";
self::parseResponse($ret);
}
the script then defines the array of the function as result
public static function parseResponse($response) {
$xml = new SimpleXMLElement($response,null,false,
'http://awis.amazonaws.com/doc/2005-07-11');
if($xml->count() && $xml->Response->TrafficHistoryResult->Alexa->count()) {
$info = $xml->Response->TrafficHistoryResult->Alexa;
$nice_array = array(
// 'City' => $info->ContactInfo->PhysicalAddress->City,
// 'State' => $info->ContactInfo->PhysicalAddress->State,
// 'Postal Code' => $info->ContactInfo->PhysicalAddress->PostalCode,
// 'Country' => $info->ContactInfo->PhysicalAddress->Country,
// 'Links In Count' => $info->ContentData->LinksInCount,
// 'Rank' => $info->TrafficData->Rank,
// 'Usage' => $info->TrafficData->UsageStatistics
'Rank' => $info->TrafficHistory->HistoricalData->Data->Rank
);
}
foreach($nice_array as $k => $v)
{
echo $k.': ' . $v ."
<br>";
}
}
UPDATE: This works. i am now able to put it in a href=XX but still update to mysql shows blanks
$accessKeyId1 = "XXX";
$secretAccessKey1 = "XXX";
$site1 = $_GET['domain'];
$StartNum1 = $_GET['currentdate'];
//$url = $urlInfo->getUrlInfo();
//echo "URL : ".$url;
function Rank($accessKeyId, $secretAccessKey, $site, $StartNum)
{$urlInfo = new UrlInfo($accessKeyId, $secretAccessKey, $site, $StartNum); $urlInfo->getUrlInfo();}
echo "test url:<a href='/";
$test = Rank($accessKeyId1, $secretAccessKey1, $site1, $StartNum1);
//$testing = mysql_query("UPDATE rank SET rank = '".Rank($accessKeyId1, $secretAccessKey1, $site1, $StartNum1)."' WHERE domain = '4shared.com'") or die(mysql_error());
echo $test."'>test</a>";
for the UPDATE i tried Rank($accessKeyId1, $secretAccessKey1, $site1, $StartNum1) and also $test.
any ideas from here?
Try, instead of $urlinfo->geturlinfo()
making another prepped statement above named something like $url = $urlinfo->geturlinfo()
,then within the statement put '$url'
so:
mysql_query("INSERT INTO rank (date, domain, rank) VALUES ('$date','$domain','$url')");
i think the main problem you are having is the quotation marks, it is splitting the statement into two parts which means the statement isn't complete (don't quote me on that)
finally do you actually have a table called rank? because it sounds like you're calling it a column/ row.
I'm only working through my own thought process, I hope this works/ helps =]
in the comments i was saying that you should do is this->
$rank = $this->url->getNewValue();
$url = $this->$rank->getUrlInfo();
mysql_query("INSERT INTO rank (date, domain, rank) VALUES ('$date','$domain','$url')");
Although i would have a look at the link below about SQL Injection
it will help protect your application from Hackers.