the-dream
08-13-2008, 11:29 AM
<?php
$url = $_SERVER['REQUEST_URI'];
$split = preg_split('/\//', $url);
mysql_connect("mysql.xxxxxxxxx.com", "xxxxxxxxx", "xxxxxxxxx");
mysql_select_db("branchr");
$user = mysql_query("SELECT * FROM social_trees WHERE username = '$split[1]'");
$branches = mysql_query("SELECT * FROM network_branches WHERE user = '$split[1]'");
$row = mysql_fetch_array($user);
$u = $split[1];
?>
<?php echo $row['username']; ?> >>
<?php
while($row1 = mysql_fetch_array($branches)) {
$brnch = $row1['id'];
$url = $row1['network_feed'];
$net = $row1['network'];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
curl_close($ch);
$doc = new SimpleXmlElement($data, LIBXML_NOCDATA);
function parseRSS($xml, $u, $net, $brnch)
{
$cnt = count($xml->channel->item);
for($i=0; $i<$cnt; $i++)
{
$url = $xml->channel->item[$i]->link;
$title = $xml->channel->item[$i]->title;
$desc = $xml->channel->item[$i]->description;
$date = $xml->channel->item[$i]->pubDate;
// But this doesnt
$isitthere = mysql_query("SELECT * FROM `data` WHERE data.title = '$title' AND data.date = '$date' AND data.user = '$u'");
$counter = 0;
while($isrow = mysql_fetch_array($isitthere)) {
$counter ++;
}
if($counter == '0') {
// The code below runs!
mysql_query("INSERT INTO data VALUES ( NULL, '$title', '$desc', '$date', '$u', '$net', '$brnch' )");
}
}
}
if(isset($doc->channel))
{
parseRSS($doc, $u, $net, $brnch);
}
}
?>
See code comments for where it is, basically the bottom SQL executes but the top one doesn't. I get the following error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/.zusa/christianowens/branchr.com/user.php on line 50
$url = $_SERVER['REQUEST_URI'];
$split = preg_split('/\//', $url);
mysql_connect("mysql.xxxxxxxxx.com", "xxxxxxxxx", "xxxxxxxxx");
mysql_select_db("branchr");
$user = mysql_query("SELECT * FROM social_trees WHERE username = '$split[1]'");
$branches = mysql_query("SELECT * FROM network_branches WHERE user = '$split[1]'");
$row = mysql_fetch_array($user);
$u = $split[1];
?>
<?php echo $row['username']; ?> >>
<?php
while($row1 = mysql_fetch_array($branches)) {
$brnch = $row1['id'];
$url = $row1['network_feed'];
$net = $row1['network'];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
curl_close($ch);
$doc = new SimpleXmlElement($data, LIBXML_NOCDATA);
function parseRSS($xml, $u, $net, $brnch)
{
$cnt = count($xml->channel->item);
for($i=0; $i<$cnt; $i++)
{
$url = $xml->channel->item[$i]->link;
$title = $xml->channel->item[$i]->title;
$desc = $xml->channel->item[$i]->description;
$date = $xml->channel->item[$i]->pubDate;
// But this doesnt
$isitthere = mysql_query("SELECT * FROM `data` WHERE data.title = '$title' AND data.date = '$date' AND data.user = '$u'");
$counter = 0;
while($isrow = mysql_fetch_array($isitthere)) {
$counter ++;
}
if($counter == '0') {
// The code below runs!
mysql_query("INSERT INTO data VALUES ( NULL, '$title', '$desc', '$date', '$u', '$net', '$brnch' )");
}
}
}
if(isset($doc->channel))
{
parseRSS($doc, $u, $net, $brnch);
}
}
?>
See code comments for where it is, basically the bottom SQL executes but the top one doesn't. I get the following error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/.zusa/christianowens/branchr.com/user.php on line 50