lordzardeck Posted January 17, 2009 Share Posted January 17, 2009 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>";?> Quote Link to comment Share on other sites More sharing options...
Mchl Posted January 17, 2009 Share Posted January 17, 2009 Change <itemid><?php echo $row_search['itemid']; ?></itemid> to <itemid>{$row_search['itemid']}</itemid> (and in all subsequent lines) Quote Link to comment Share on other sites More sharing options...
lordzardeck Posted January 17, 2009 Author Share Posted January 17, 2009 Now I get the error : Parse error: syntax error, unexpected '}' in /homepages/36/d134836550/htdocs/test/admin/xmlsearch.php on line 140 I edited the code to match the new file. Quote Link to comment Share on other sites More sharing options...
Mchl Posted January 17, 2009 Share Posted January 17, 2009 There's missing ; at the and of line 139 Quote Link to comment Share on other sites More sharing options...
lordzardeck Posted January 17, 2009 Author Share Posted January 17, 2009 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? Quote Link to comment Share on other sites More sharing options...
Mchl Posted January 17, 2009 Share Posted January 17, 2009 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'); Quote Link to comment Share on other sites More sharing options...
lordzardeck Posted January 22, 2009 Author Share Posted January 22, 2009 Whoops, I didn't put the connection details of the server. Thanks! Quote Link to comment Share on other sites More sharing options...
lordzardeck Posted January 22, 2009 Author Share Posted January 22, 2009 Hey, is there a javascript script to show all errors just like that php one? Quote Link to comment Share on other sites More sharing options...
premiso Posted January 22, 2009 Share Posted January 22, 2009 Hey, is there a javascript script to show all errors just like that php one? Using FireFox there is an Error Console log that tells you all javascript errors. I am sure IE has an addon to do the same. Quote Link to comment Share on other sites More sharing options...
lordzardeck Posted January 22, 2009 Author Share Posted January 22, 2009 How do you find it? I mean where in firefox is it and how do you use it? Quote Link to comment Share on other sites More sharing options...
premiso Posted January 22, 2009 Share Posted January 22, 2009 How do you find it? I mean where in firefox is it and how do you use it? Tools > Error Console Quote Link to comment Share on other sites More sharing options...
lordzardeck Posted January 23, 2009 Author Share Posted January 23, 2009 Yeah, I see it but it didn't do me any good. Ended up finding out problem after lots of trial and error. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.