Jump to content

Recommended Posts

For some reason I cannot get this xml generation script to work. I think it has something to do with tags. I keep getting this error : Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /homepages/36/d134836550/htdocs/test/admin/xmlsearch.php on line 97

 

Here is the script. It's pretting long.

 

<?php
$currentPage = $_SERVER["PHP_SELF"];

$txtTitle = "";
if (isset($_GET["titlesearch"])) {
  $txtTitle = $_GET["titlesearch"];
}

$txtPublisher = "";
if (isset($_GET["publishersearch"])) {
  $txtPublisher = $_GET["publishersearch"];
}

$txtGrade = "";
if (isset($_GET["gradesearch"])) {
  $txtGrade = $_GET["gradesearch"];
}

$txtSubject = "";
if (isset($_GET["subjectsearch"])) {
  $txtSubject = $_GET["subjectsearch"];
}

$txtAccession = "";
if (isset($_GET["accessionsearch"])) {
  $txtAccession = $_GET["accessionsearch"];
}

$maxRows_search = 10;
$pageNum_search = 0;
if (isset($_GET['pageNum_search'])) {
  $pageNum_search = $_GET['pageNum_search'];
}

$startRow_search = $pageNum_search * $maxRows_search;

mysql_select_db($database_saccatalog, $saccatalog);

$query_search= "SELECT item.itemid, item.accessionnum, item.isbn, item.lccn, item.dewey, item.author, item.illustrator, item.title, item.responsibility, item.edition, item.pubplace, item.publisher, item.pubdate, item.series, item.seriesnum, item.extent, item.illustrations, item.condition, item.price, item.source, item.entrydate, itemsubject.subjectid, itemsubject.itemid AS subject_itemid, itemsubject.subject, circulation.circulationid, circulation.itemid AS circulation_itemid, circulation.accessionnum AS circulation_accessionnum, circulation.patronid, circulation.dateout, circulation.datedue
FROM item LEFT OUTER JOIN itemsubject on itemsubject.itemid=item.itemid LEFT OUTER JOIN circulation on circulation.itemid=item.itemid WHERE ";

$sstring=$txtTitle;
$sstringarray=explode(' ',$sstring);
$wordcount=count($sstringarray);
$loopcount=1;
$and='OR ';
foreach($sstringarray as $keyword){
if ($wordcount==$loopcount){$and='';}
$query_search.= 'item.title LIKE \'%'.$keyword.'%\' '.$and.' ';
$loopcount++;}
$query_search.= " AND ";

$query_search.= 'item.accessionnum LIKE \'%'.$txtAccession.'%\' AND ';

$sstring="$txtPublisher";
$sstringarray=explode(' ',$sstring);
$wordcount=count($sstringarray);
$loopcount=1;
$and='OR ';
foreach($sstringarray as $keyword){
if ($wordcount==$loopcount){$and='';}
$query_search.= 'item.publisher LIKE \'%'.$keyword.'%\' '.$and.' ';
$loopcount++;}
$query_search.= " AND ";

$sstring=$txtGrade;
$sstringarray=explode(' ',$sstring);
$wordcount=count($sstringarray);
$loopcount=1;
$and='OR ';
foreach($sstringarray as $keyword){
if ($wordcount==$loopcount){$and='';}
$query_search.= 'itemsubject.subject LIKE \'%'.$keyword.'%\' '.$and.' ';
$loopcount++;}
$query_search.= " AND ";

$sstring=$txtSubject;
$sstringarray=explode(' ',$sstring);
$wordcount=count($sstringarray);
$loopcount=1;
$and='OR ';
foreach($sstringarray as $keyword){
if ($wordcount==$loopcount){$and='';}
$query_search.= 'itemsubject.subject LIKE \'%'.$keyword.'%\' '.$and.' ';
$loopcount++;}

$search = mysql_query($query_search, $saccatalog) or die(mysql_error());
$row_search = mysql_fetch_assoc($search);

print "<?xml version='1.0' endcoding='utf-8' ?>
<search>";

do { 

print "<bookdetail>
<item>
        <itemid>{$row_search['itemid'] }</itemid>
        <accessionnum>{$row_search['accessionnum'] }</accessionnum>
        <isbn>{$row_search['isbn'] }</isbn>
        <lccn>{$row_search['lccn'] }</lccn>
        <dewey>{$row_search['dewey'] }</dewey>
        <author>{$row_search['author'] }</author>
        <illustrator>{$row_search['illustration'] }</illustrator>
        <title>{$row_search['title'] }</title>
        <responsibility>{$row_search['responsibility'] }</responsibility>
        <edition>{$row_search['edition'] }</edition>
        <pubplace>{$row_search['pubplace'] }</pubplace>
        <publisher>{$row_search['publisher'] }</publisher>
        <pubdate>{$row_search['pubdate'] }</pubdate>
        <series>{$row_search['series'] }</series>
        <seriesnum>{$row_search['seriesnum'] }</seriesnum>
        <extent>{$row_search['extent'] }</extent>
        <illustrations>{$row_search['illustrations'] }</illustrations>
        <binding>{$row_search['binding'] }</binding>
        <condition>{$row_search['condition'] }</condition>
        <price>{$row_search['price'] }</price>
        <source>{$row_search['source'] }</source>
        <curriculumareaid>{$row_search['curriculumareaid'] }</curriculumareaid>
        <gradelevelid>{$row_search['gradelevelid'] }</gradelevelid>
        <materialtypeid>{$row_search['materialtypeid'] }</materialtypeid>
        <formatid>{$row_search['formatid'] }</formatid>
        <circulationtype>{$row_search['curculationtype'] }</circulationtype>
        <entrydate>{$row_search['entrydate'] }</entrydate>
</item>
<circulation>
        <circulationid>{$row_search['circulationid'] }</circulationid>
        <itemid>{$row_search['circulation_itemid'] }</itemid>
        <accessionnum>{$row_search['circulation_accessionnum'] }</accessionnum>
        <patronid>{$row_search['patronid'] }</patronid>
        <circulationtypeid>{$row_search['circulationtypeid'] }</circulationtypeid>
        <dateout>{$row_search['dateout'] }</dateout>
        <datedue>{$row_search['datedue'] }</datedue>
</circulation>
<itemsubject>
        <subjectid>{$row_search['subjectid'] }</subjectid>
        <itemid>{$row_search['subject_itemid'] }</itemid>
        <subject>{$row_search['subject'] }</subject>
</itemsubject>
</bookdetail>"
} while ($row_search = mysql_fetch_assoc($search));
print "</search>";?>

Link to comment
https://forums.phpfreaks.com/topic/141252-solved-xml-generation-error/
Share on other sites

Well, i had no errors this time, but No code showed. Here is a link to the file: http://sac-online.org/test/admin/xmlsearch.php . No code showed up in view page source either. I don't know much about xml but is it supposed to show?

 

It should show something in the source code at least.

Try adding these two lines at the very beginning of your code (just after <?php

 

<?php
error_reporting(E_ALL);
ini_set('diplay_errors', 'On');

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.