PHP search - return link from xml and load into JW Player

I have never worked with PHP before, but I want to do a keyword search of 1000 videos and load the result into a flash player for a video-art project.

I know I can load a link in the player with this code:

<a href="#" onclick="jwplayer().load('http://www.projectoctober.com/clip/swamp/swamp1.mp4')">

So I tried to integrate that with some PHP code that I found (this was working but the link pointed directly to the video - so I tried adding an onclick attribute)

[php]<?php
$xmlDoc = new DOMDocument();
$xmlDoc->load(“links.xml”);
$x = $xmlDoc->getElementsByTagName(‘item’);
$q = $_GET[“q”];
if (strlen($q) > 0) {
$hint = “”;
for ($i = 0; $i < ($x->length); $i++) {
$v = $x->item($i)->getElementsByTagName(‘title’);
$y = $x->item($i)->getElementsByTagName(‘keyword’);
$z = $x->item($i)->getElementsByTagName(‘url’);
if ($y->item(0)->nodeType == 1) {
if (stristr($y->item(0)->childNodes->item(0)->nodeValue, $q)) {
if ($hint == “”) {
$hint = “<a href=’” . “’ onclick=’“jwplayer() . load( / ’ . $z->item(0)->childNodes->item(0)->nodeValue . /’)”’>” . $v->item(0)->childNodes->item(0)->nodeValue . “”;
} else {
$hint = $hint . “
<a href=’” . “’ onclick=’“jwplayer() . load( / ’ . $z->item(0)->childNodes->item(0)->nodeValue . /’)”’>” . $v->item(0)->childNodes->item(0)->nodeValue . “”;
}
}
}
}
}
if ($hint == “”) {
$response = “no suggestion”;
} else {
$response = $hint;
}
echo $response;
?>[/php]

I keep getting errors on the first line that uses the onclick attribute. I hope it is something simple with my syntax. Any help would be great!

You can see how I am using it here http://private.projectoctober.com/swampex.html

I have done some work on the part of the php that was returning the syntax error, and now my result is returning and it is sending something to JW Player!

The problem is that what ever it is sending is incorrect, and I can’t tell what it is…

Here is the site - http://private.projectoctober.com/swampex.html - search the keyword ‘black’ ‘cloud’ or ‘rain’ and click the result to see the problem.

Thanks!!

Here are the pertinent lines of code…

[php]
{
if ($hint == “”) {
$hint = “<a href=”." onclick=“jwplayer() . load(’$z->item(0)->childNodes->item(0)->nodeValue’)”>" . $v->item(0)->childNodes->item(0)->nodeValue . “”;
} else {
$hint = $hint . “
<a href=”." onclick=“jwplayer() . load(’$z->item(0)->childNodes->item(0)->nodeValue’)”>" . $v->item(0)->childNodes->item(0)->nodeValue . “”;
}
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service