List Info

Thread: Newbie question on yaz-php




Newbie question on yaz-php
user name
2007-03-19 09:59:57
I've been trying my hand at yaz via php.
I should say that I know nothing of yaz, and little of php.
Perhaps because of this, I have had no success.
Here is a sample php program.
Could some kind soul please tell me why I seem to get no
success?

I should say that I am testing this on a machine running
Fedora 6 Linux.
-------------------------------------------------------
<html>
<body>

<?php
  $query="attr 1=7 0521458862";
  $host="z3950.loc.gov:7090/voyager";
echo "Trying to connect to $host ... ";
  $id = yaz_connect($host);
echo "Connected; ";
  yaz_syntax($id, "usmarc");
  yaz_range($id, 1, 10);
  yaz_search($id, "rpn", $query);
  yaz_wait();
  echo '<hr />' . $host . ':';
  $error = yaz_error($id);
  if (!empty($error)) {
    echo "Error: $error";
  } else {
    $hits = yaz_hits($id);
    echo "Result Count $hits";
  }
  echo '<dl>';
  for ($p = 1; $p <= 10; $p++) {
    $rec = yaz_record($id, $p, "string");
    if (empty($rec)) continue;
    echo
"<dt><b>$p</b></dt><dd>&q
uot;;
    echo nl2br($rec);
    echo "</dd>";
  }
  echo '</dl>';
?> 

</body>
</html>
-------------------------------------------------------

A couple of comments.

Fedora 6 did not seem to have the yaz-php module
(as shown by the fact that it reported that 
the function yaz_connect() was unknown).
So I downloaded the source as yaz-1.0.8.tgz,
expanded it and ran "pecl build package.xml".

I don't really know if that is what one is meant to do,
but it seemed to work, in so far as there was no longer
a complaint that yaz_connect() was unknown.

Now when I browse to foo.php (the above file) on my
web-server
the program does not seem to get past the yaz_connect()
line.

If anyone has a simple program like this which works for
them,
I'd very much like to see it;
I didn't find any small examples of yaz-php usage
on a brief google search.



-- 
Timothy Murphy  
e-mail (<80k only): tim /at/ birdsnest.maths.tcd.ie
tel: +353-86-2336090, +353-1-2842366
s-mail: School of Mathematics, Trinity College, Dublin 2,
Ireland

_______________________________________________
Yazlist mailing list
Yazlistlists.indexdata.dk
http://lists.indexdata.dk/cgi-bin/mailman/listinfo/yaz
list

Re: Newbie question on yaz-php
country flaguser name
Denmark
2007-03-19 10:21:16


Timothy Murphy wrote:
birdsnest.maths.tcd.ie" type="cite">
I've been trying my hand at yaz via php.
I should say that I know nothing of yaz, and little of php.
Perhaps because of this, I have had no success.
Here is a sample php program.
Could some kind soul please tell me why I seem to get no success?

I should say that I am testing this on a machine running Fedora 6 Linux.
-------------------------------------------------------
<html>;
<body>

<;?php
  $query="attr 1=7 0521458862";
  $host="z3950.loc.gov:7090/voyager";
echo "Trying to connect to $host ... ";
  $id = yaz_connect($host);
echo "Connected; ";
  yaz_syntax($id, "usmarc");
  yaz_range($id, 1, 10);
  yaz_search($id, "rpn", $query);
  yaz_wait();
  echo '<hr />' . $host . ':';
  $error = yaz_error($id);
  if (!empty($error)) {
    echo "Error: $error";
  } else {
    $hits = yaz_hits($id);
    echo "Result Count $hits";
  }
  echo '<dl>;';
  for ($p = 1; $p <= 10; $p++) {
    $rec = yaz_record($id, $p, "string");
    if (empty($rec)) continue;

    echo "<dt>;<b>$p</b></dt><dd>";
    echo nl2br($rec);
    echo "</dd&gt;";
  }
  echo '</dl&gt;';
?> 

</body>
&lt;/html>
-------------------------------------------------------

A couple of comments.


Fedora 6 did not seem to have the yaz-php module
(as shown by the fact that it reported that 
the function yaz_connect() was unknown).

So I downloaded the source as yaz-1.0.8.tgz,
expanded it and ran "pecl build package.xml".

I don't really know if that is what one is meant to do,
but it seemed to work, in so far as there was no longer
a complaint that yaz_connect() was unknown.

Now when I browse to foo.php (the above file) on my web-server
the program does not seem to get past the yaz_connect() line.

If anyone has a simple program like this which works for them,
I'd very much like to see it;
I didn't find any small examples of yaz-php usage
on a brief google search.


  
On our Debian box it works just fine:
Trying to connect to z3950.loc.gov:7090/voyager ... Connected;
z3950.loc.gov:7090/voyager:Result Count 1
1
01346cam 2200361 a 4500
001 3971865
005 20020828202342.0
008 931201s1993 enk b 001 0 eng d
035 $9 (DLC) 94211280
906 $a 7 $b cbc $c copycat $d 2 $e ncip $f 19 $g y-gencatlg
955 $a ud08 to cat 09-21-94; jd00 10-21-94; jd20 10-21-94; jd99 10-21-94;; jd85 10-21-94
010 $a 94211280
015 $a GB93-61926
020 $a 0521458862
035 $a (OCoLC)29409678
040 $a OAU $c OAU $d WU $d Uk $d DLC
042 $a lccopycat
050 04 $a QA201 $b .B46 1993
082 00 $a 512./5 $2 20
100 1 $a Benson, D. J. $q (David J.), $d 1955-
245 10 $a Polynomial invariants of finite groups / $c D.J. Benson.
260 $a Cambridge ; $a New York : $b Cambridge University Press, $c c1993.
300 $a ix, 118 p. ; $c 23 cm.
440 0 $a London Mathematical Society lecture note series ; $v 190
504 $a Includes bibliographical references (p. 109-115) and index.
650 0 $a Invariants.
650 0 $a Finite groups.
650 0 $a Divisor theory.
653 0 $a Groups (Mathematics)
856 42 $3 Publisher description $u http://www.loc.gov/catdir/description/cam026/94211280.html
856 41 $3 Table of contents $u http://www.loc.gov/catdir/toc/cam027/94211280.html
922 $a co
991 $b c-GenColl $h QA201 $i .B46 1993 $p 00035006230 $t Copy 1 $v 190 $w BOOKS
Are you sure that port 7090 is open for outward traffic? Can you connect to the target using yaz-client?

Regards,

Per Hansen
Index Data

Re: Newbie question on yaz-php
user name
2007-03-23 08:49:32
On Mon 19 Mar 2007, Per M. Hansen wrote:

> Timothy Murphy wrote:
> > I've been trying my hand at yaz via php.
> > I should say that I know nothing of yaz, and
little of php.
> > Perhaps because of this, I have had no success.
> > Here is a sample php program.
> > Could some kind soul please tell me why I seem to
get no success?
> >
> > I should say that I am testing this on a machine
running Fedora 6 Linux.

Just a note to thank those who responded to my query.
In the end I found I had made two errors or omissions:

Firstly, when adding yaz/php to my php I should have said
	pecl install yaz
rather than saying "pecl build".

Secondly, I had to add the line
	AddType application/x-httpd-php .php
to /etc/httpd/conf/httpd.conf on my server.


	
	



-- 
Timothy Murphy  
e-mail (<80k only): tim /at/ birdsnest.maths.tcd.ie
tel: +353-86-2336090, +353-1-2842366
s-mail: School of Mathematics, Trinity College, Dublin 2,
Ireland

_______________________________________________
Yazlist mailing list
Yazlistlists.indexdata.dk
http://lists.indexdata.dk/cgi-bin/mailman/listinfo/yaz
list

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )