/    Sign up×
Community /Pin to ProfileBookmark

Help please

I’m very newbie to php so forgive my ignorance if any!
I’m trying to get stream to show if online or offline, the check.php works just fine if i don’t have “$f3” in “line 5” but I need to collect from array and put into there.

If I add a space it will show my value in the spot but then I get %20 which i can’t have.

Well anyway the error I’m getting is

[code]Warning: DOMDocument::load() [domdocument.load]: Couldn’t resolve host name in /home/dahdop/public_html/pvpstreams.com/table/check.php on line 5

Warning: DOMDocument::load(http://x.api.channel.livestream.com/2.0/livestatus.xml) [domdocument.load]: failed to open stream: operation failed in /home/dahdop/public_html/pvpstreams.com/table/check.php on line 5

Warning: DOMDocument::load() [domdocument.load]: I/O warning : failed to load external entity “http://x.api.channel.livestream.com/2.0/livestatus.xml” in /home/dahdop/public_html/pvpstreams.com/table/check.php on line 5
Offline | Viewers: [/code]

To me its taking away an “x” and making the array blank for some reason.

My site is pvpstreams.com if you want to see error in action.

My table.php file

[code]<script language=”javascript”>

imageX1=’plus’;
imageX2=’plus’;
imageX3=’plus’;

function toggleDisplay(e){
imgX=”imagePM”+e;
tableX=”table”+e;
imageX=”imageX”+e;
tableLink=”tableHref”+e;
imageXval=eval(“imageX”+e);
element = document.getElementById(tableX).style;
if (element.display==’none’) {element.display=’block’;}
else {element.display=’none’;}
if (imageXval==’plus’) {document.getElementById(imgX).src=’http://www.pvpstreams.com/icons/wowicon.png’;eval(“imageX”+e+”=’minus’;”);document.getElementById(tableLink).title=’Hide WoW’;}
else {document.getElementById(imgX).src=’http://www.pvpstreams.com/icons/wowicon.png’;eval(“imageX”+e+”=’plus’;”);document.getElementById(tableLink).title=’Show WoW’;}
}
</script>

<?php
$username=”x”;
$password=”x”;
$tmp=”x”;

mysql_connect(localhost,$username,$password);
@mysql_select_db($tmp) or die( “Unable to select database”);
$query=”SELECT * FROM users”;
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();
?>
<table class=”sortable” id=”wow” border=”1″ cellpadding=”0″ cellspacing=”0″ style=”margin-left:auto;margin-right:auto;text-align:left”>
<tr>
<th><font face=”Arial, Helvetica, sans-serif”>Character</font></th>
<th><font face=”Arial, Helvetica, sans-serif”>Xfire</font></th>
<th><font face=”Arial, Helvetica, sans-serif”>Livestream</font></th>
<th><font face=”Arial, Helvetica, sans-serif”>Livestream&nbsp;Status</font></th>
<th><font face=”Arial, Helvetica, sans-serif”>Team&nbsp;Members</font></th>
<th><font face=”Arial, Helvetica, sans-serif”>Realm</font></th>
</tr>

<?php
$i=0;
while ($i < $num) {

$f1=mysql_result($result,$i,”wowcharacter”);
$f2=mysql_result($result,$i,”username”);
$f3=mysql_result($result,$i,”livestream”);
$f4=mysql_result($result,$i,”wowserver”);

$f5=mysql_result($result,$i,”wowplayer1″);
$f6=mysql_result($result,$i,”wowplayer2″);
$f9=mysql_result($result,$i,”wowplayer3″);

$f7=mysql_result($result,$i,”wowrealm”);
$f8=mysql_result($result,$i,”xfire”);
?>

<tr>
<td><font face=”Arial, Helvetica, sans-serif”><?php Echo “<a class=blue href=http://$f9.battle.net/wow/en/character/$f7/$f1/simple>$f1</a>”; ?></font></td>
<td><font face=”Arial, Helvetica, sans-serif”><?php Echo “<a class=blue href=http://www.pvpstreams.com/xfire.php?user=$f2>$f8</a>”; ?></font></td>
<td><font face=”Arial, Helvetica, sans-serif”><?php echo “<a class=blue href=http://www.pvpstreams.com/livestream.php?user=$f2>$f3</a>”; ?></font></td>
<td><font face=”Arial, Helvetica, sans-serif”>

<?php include(“check.php”); ?>

</font></td>
<td><font face=”Arial, Helvetica, sans-serif”><?php echo “<img src=wclassicons/$f5.png><img src=wclassicons/$f6.png><img src=wclassicons/$f9.png>” ?></font></td>
<td><font face=”Arial, Helvetica, sans-serif”><?php echo $f7; ?></font></td>
</tr>

<?php
$i++;
}
?>
</table>[/code]

My check.php file

[code]
<?php

$objDOM = new DOMDocument();
// channel name here **INSERT**
$objDOM->load(“http://x$f3x.api.channel.livestream.com/2.0/livestatus.xml”);

//make sure path is correct
$channel = $objDOM->getElementsByTagName(“channel”);
foreach( $channel as $value )
{
$isLives = $value->getElementsByTagName(“isLive”);
$isLive = $isLives->item(0)->nodeValue;
$viewers = $value->getElementsByTagName(“currentViewerCount”);
$viewer = $viewers->item(0)->nodeValue;
}

if($isLive == “true”)
{
echo “<font color=’#00FF00′>Online</font>”;
echo ” | Viewers: ” . $viewer;
}
else
{
echo “<font color=’#FF0000′>Offline</font>”;
echo ” | Viewers: ” . $viewer;
}
?>[/code]

Any help appreciated!

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@Matt_DMar 16.2011 — have you tried:

[CODE]

$objDOM->load("http://x".$f3."x.api.channel.livestream.com/2.0/livestatus.xml");

[/CODE]


so that PHP sees it as [I]"text"[/I][B].PHP_CODE.[/B][I]"text"[/I]
Copy linkTweet thisAlerts:
@iosysauthorMar 16.2011 — Thanks I also figured out that you can do {} for the php code but I'll remember that advice too.
×

Success!

Help @iosys spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...