Jump to content

rdrews

Members
  • Posts

    26
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

rdrews's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I get: Warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: xmlParseEntityRef: no name in Entity, line: 1 in /path/to/page.php on line 106 Warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: xmlParseEntityRef: no name in Entity, line: 1 in /path/to/page.php on line 106 Line 106 is: $xmlDoc->loadXML($tmpDoc);
  2. I have some code that works fine on my dev server but does not work on my production server. Dev server has PHP version 5.2.5 and production server has PHP version 5.1.6. This is the part of the code that isn't working on the prod. server: $xmlDoc=new DOMDocument(); $xmlDoc->loadXML($tmpDoc); $x=$xmlDoc->getElementsByTagName('link'); //get the q parameter from URL $q=$_GET["q"]; //lookup all links from the xml file if length of q>0 if (strlen($q)>0) { $hint=""; for($i=0; $i<($x->length); $i++) { $y=$x->item($i)->getElementsByTagName('title'); $z=$x->item($i)->getElementsByTagName('url'); if ($y->item(0)->nodeType==1) { //find a link matching the search text if (stristr($y->item(0)->childNodes->item(0)->nodeValue,$q)) { if ($hint=="") { $hint="<tr><td><a href='" . $z->item(0)->childNodes->item(0)->nodeValue . "' target='_blank'>" . $y->item(0)->childNodes->item(0)->nodeValue . "</td></tr>"; } else { $hint=$hint . "<tr><td><a href='" . $z->item(0)->childNodes->item(0)->nodeValue . "' target='_blank'>" . $y->item(0)->childNodes->item(0)->nodeValue . "</a></td></tr>"; } } } } } $tmpDoc is a variable that holds database information in xml form. It basically looks like this: $tmpDoc = $tmpDoc . "<link><title>" . $row['CustomerName'] . "****" . $row['Rep'] . "****" . $row['InstallDate'] . "****" . $row['PaidDate'] . "</title><url>accountPage.php?AccNum=" . $row['AccountNum'] . "</url></link>"; ...that is inside a while loop that loops through the rows returned by a query. Basically, as I said, the whole thing works fine on my dev server but on the production server it never makes it into the for loop so I guess the condition $i<($x->length) isn't being met. I'm at a bit of a loss here. Is there anything like the PHP version or Apache version that may cause the "->" operator to not work? The prod PHP version isn't that much older than my dev PHP version so I doubt that's the issue but it's about all I can think of. Thanks!
  3. Amazing, worked like a charm, thanks!
  4. I'm trying to get live search set up for one of my pages and have been successful for the most part. I basically used the code provided by w3schools (http://www.w3schools.com/php/php_ajax_livesearch.asp) but need to make a modification. Their code is set up to read the link titles and urls from an xml file and search through the xml file but I would like to just search through a variable. So in the w3schools code there is this... $xmlDoc=new DOMDocument(); $xmlDoc->load("links.xml"); $x=$xmlDoc->getElementsByTagName('link'); And I have this variable that I want it to search instead of "links.xml"... $searchTest = "<pages><link><title>Search this text</title><url>www.gohere.com</url></link></pages>"; How do I get that into the $xmlDoc variable? If I simply replace "links.xml" with $searchTest like this $xmlDoc=new DOMDocument(); $xmlDoc->load($searchTest); $x=$xmlDoc->getElementsByTagName('link'); I get nothing when I try to search. But if I create a file in the php code and write the contents of $searchTest to that file then put that file in the $xmlDoc->load("newfile.xml"); line it searches and works fine. Any ideas?
  5. Cags!!! Thanks for the help again. I'm still working through the problem I was having a few days ago and I'm using both of your solutions to get through it. I think I've finally got it working now. Thanks again!
  6. I need a function that will search a string and return the contents of the string between two other strings. For example: $str = "1234567 this is a test and I want this text 999999"; $start = "1234567"; $end = "999999"; $textIWant = " this is a test and I want this text "; So basically I have a huge string and I want to search it for some starting string and copy all the contents between the starting string and a defined ending string into another variable. Can this be done easily? Thanks
  7. Posted this here http://www.phpfreaks.com/forums/index.php/topic,280070.0.html but don't seem to be getting a lot of assistance (cags actually provided great help but I'm still lost) so I figure maybe regex isn't the right way to go (also suggested by cags). Here is my problem... Ok, here is a sample of the string I need broken up... ******Begin Sample********* <div class="PubSectionHeader"><font size="+0">Bill Smith 48415126</font></div> <br> <a name="NDR4pDQoQv5rq1MQk"></a> <div class="PubNote"> <div class="PubNoteContentArea">Called Customer and blah blah blah blah. abc. 10/12/09<blockquote class="gn_c"> She doesn&#39;t want to be contacted on this number but said okay. 10/12/09</blockquote></div> </div> <a name="NDRLWDAoQ2qq687wk"></a> <div class="PubNote"> <div class="PubNoteContentArea">Spoke to customer on alternate number. She said she blah blah blah blah blah. I told her as long as we receive it within a week, no problems. abc 9/18/09</div> </div> <a name="NDRykDAoQv__VvaUk"></a> <div class="PubNote"> <div class="PubNoteContentArea">Left message on premise about issues. abc 7/7/09</div> </div> <a name="NDQrlDAoQxbL1_54k"></a> <div class="PubNote"> <div class="PubNoteContentArea">this is another part of the comment that I need. I think I am going about things the wrong way. abc 6/17/09<blockquote class="gn_c"> She said she&#39;ll call tech support. abc 6/17/09</blockquote></div> </div> <a name="NDQopDQoQ18mwt5wk"></a> <div class="PubNote"> <div class="PubNoteContentArea">Called customer about issue. Left message on alternate number. abc 6/9/09 </div> </div> <a name="NDQduDQoQoNiBhZMk"></a> <div class="PubNote"> <div class="PubNoteContentArea">call was returned &#39;. abc 5/11/09<blockquote class="gn_c"> Customer said she doesn&#39;t want to be transferred to tech support (even though she said her system doesn&#39;t work). She asked why we&#39;re so hard to get a hold of. I let her know she can call the number to contact us. abc 5/11/09<br>Removed from list. abc 5/11/09</blockquote></div> </div> <a name="NDQ7QIgoQ9aWRsJgj"></a> <div class="PubNote"> <div class="PubNoteContentArea">Big problems. abc </div> </div> <a name="SDUThIgoQrLX5r5gj"></a> <div class="PubSectionHeader"><font size="+0">Mark and Larry 700002</font></div> <br> <a name="NDSOkDAoQ5-TduIgk"></a> <div class="PubNote"> <div class="PubNoteContentArea"><span>update per user, told the customer if he gets two remotes we can wave fee . bill 04/08/09 2:00 pm </span><div> </div></div> </div> <a name="NDQmeDQoQjdS-uIgk"></a> <div class="PubNote"> <div class="PubNoteContentArea">yada yada yada yada . <div>bill 04/08/09</div></div> </div> <a name="NDSGpIgoQ56b7r5gj"></a> <div class="PubNote"> <div class="PubNoteContentArea">another note here. abc </div> </div> <a name="SDQqRIwoQyIDmr5gj"></a> *********End Sample************** Ok...all of this is HTML source from Google Docs that I saved into a large .txt file. Basically, I need all of this broken into two parts. Account numbers and comments. All the account numbers are found right after the name which is AFTER the <div class="PubSectionHeader"><font size="+0"> and BEFORE the </font> And all the comments look to be between <div class="PubNoteContentArea"> and </div> but there are usually several separate notes for each account number. So a single account number may have several <div class="PubNoteContentArea"> note areas. Ideally I would like to run through this whole text file and end up with two arrays. One array would be all account numbers (accountNum[0] = "123", accountNum[1] = "456", etc...) and the other array would be all the notes (notes[0] = "notes for account 123", notes[1] = "notes for account 456", etc...) but if it's easier/makes more sense to do one array where the first element would be the account number, the second the notes for the account in the first element, the third, another account number, etc.... then I can work with that too. I realize there is some additional formatting in between some of the <div class="PubNoteContentArea"> note areas like "<blockquote class="gn_c">" and maybe some other stuff but for now I'm not really worried about all that. I can maybe put the whole file into word or excel and do a few find/replaces to get rid of some of that. Up to this point I have loaded the whole file contents into a string and then split the string into a character array where every character (including whitespaces) is an element in the array. I then tried to start messing with the regex part of it and decided I wasn't getting anywhere after a while of playing around with it. Any help is greatly appreciated. If I didn't explain things very well feel free to ask me to clarify. UPDATE* With Cags provided code I get $matches[2] which holds all the account numbers for me but I can't figure out how to get all the notes associated with all those account numbers. It won't be as straight forward as getting the account numbers (I think) because there may be several notes per account number. If I am going about this the wrong way (with regex) suggestions are more than welcome. Thanks!
  8. No one? Is there another route I should be taking here?
  9. Ok...so with your help I get $matches[2] which holds all the account numbers so that's step one. I've been working on step two and can't quite get there...apparently I need to be spoon fed. I'm having trouble figuring out how to get ALL the notes under a particular account number into one element of an array. If I use something like $pattern = '#<div class="PubNoteContentArea">.</div>#is'; preg_match_all($pattern, $contents, $matches); (which I haven't gotten working quite yet) won't that just put each note between the div tags into a separate element? How do I tell it to combine all the notes after one account number and before the next account number into one element? I know that cags mentioned possibly using DOMDocument(). Should I post this somewhere else or can this be done using regex? Thanks again for the help!
  10. Awesome, thanks! That looks like it is very close to what I am looking for. I will play with it for a little bit and come back if I have anymore issues.
  11. ...I forgot to mention... The above example would be two accounts if it isn't immediately clear. The first is account number 48415126 and the second is account number 700002.
  12. Ok, here is a sample of the string I need broken up... ******Begin Sample********* <div class="PubSectionHeader"><font size="+0">Bill Smith 48415126</font></div> <br> <a name="NDR4pDQoQv5rq1MQk"></a> <div class="PubNote"> <div class="PubNoteContentArea">Called Customer and blah blah blah blah. abc. 10/12/09<blockquote class="gn_c"> She doesn&#39;t want to be contacted on this number but said okay. 10/12/09</blockquote></div> </div> <a name="NDRLWDAoQ2qq687wk"></a> <div class="PubNote"> <div class="PubNoteContentArea">Spoke to customer on alternate number. She said she blah blah blah blah blah. I told her as long as we receive it within a week, no problems. abc 9/18/09</div> </div> <a name="NDRykDAoQv__VvaUk"></a> <div class="PubNote"> <div class="PubNoteContentArea">Left message on premise about issues. abc 7/7/09</div> </div> <a name="NDQrlDAoQxbL1_54k"></a> <div class="PubNote"> <div class="PubNoteContentArea">this is another part of the comment that I need. I think I am going about things the wrong way. abc 6/17/09<blockquote class="gn_c"> She said she&#39;ll call tech support. abc 6/17/09</blockquote></div> </div> <a name="NDQopDQoQ18mwt5wk"></a> <div class="PubNote"> <div class="PubNoteContentArea">Called customer about issue. Left message on alternate number. abc 6/9/09 </div> </div> <a name="NDQduDQoQoNiBhZMk"></a> <div class="PubNote"> <div class="PubNoteContentArea">call was returned &#39;. abc 5/11/09<blockquote class="gn_c"> Customer said she doesn&#39;t want to be transferred to tech support (even though she said her system doesn&#39;t work). She asked why we&#39;re so hard to get a hold of. I let her know she can call the number to contact us. abc 5/11/09<br>Removed from list. abc 5/11/09</blockquote></div> </div> <a name="NDQ7QIgoQ9aWRsJgj"></a> <div class="PubNote"> <div class="PubNoteContentArea">Big problems. abc </div> </div> <a name="SDUThIgoQrLX5r5gj"></a> <div class="PubSectionHeader"><font size="+0">Mark and Larry 700002</font></div> <br> <a name="NDSOkDAoQ5-TduIgk"></a> <div class="PubNote"> <div class="PubNoteContentArea"><span>update per user, told the customer if he gets two remotes we can wave fee . bill 04/08/09 2:00 pm </span><div> </div></div> </div> <a name="NDQmeDQoQjdS-uIgk"></a> <div class="PubNote"> <div class="PubNoteContentArea">yada yada yada yada . <div>bill 04/08/09</div></div> </div> <a name="NDSGpIgoQ56b7r5gj"></a> <div class="PubNote"> <div class="PubNoteContentArea">another note here. abc </div> </div> <a name="SDQqRIwoQyIDmr5gj"></a> *********End Sample************** Ok...all of this is HTML source from Google Docs that I saved into a large .txt file. Basically, I need all of this broken into two parts. Account numbers and comments. All the account numbers are found right after the name which is AFTER the <div class="PubSectionHeader"><font size="+0"> and BEFORE the </font> And all the comments look to be between <div class="PubNoteContentArea"> and </div> but there are usually several separate notes for each account number. So a single account number may have several <div class="PubNoteContentArea"> note areas. Ideally I would like to run through this whole text file and end up with two arrays. One array would be all account numbers (accountNum[0] = "123", accountNum[1] = "456", etc...) and the other array would be all the notes (notes[0] = "notes for account 123", notes[1] = "notes for account 456", etc...) but if it's easier/makes more sense to do one array where the first element would be the account number, the second the notes for the account in the first element, the third, another account number, etc.... then I can work with that too. I realize there is some additional formatting in between some of the <div class="PubNoteContentArea"> note areas like "<blockquote class="gn_c">" and maybe some other stuff but for now I'm not really worried about all that. I can maybe put the whole file into word or excel and do a few find/replaces to get rid of some of that. Up to this point I have loaded the whole file contents into a string and then split the string into a character array where every character (including whitespaces) is an element in the array. I then tried to start messing with the regex part of it and decided I wasn't getting anywhere after a while of playing around with it. Any help is greatly appreciated. If I didn't explain things very well feel free to ask me to clarify. Thanks!
  13. Okay, thanks for the help guys. I was just trying to keep the code to a minimum using that function but I went ahead and pulled the query out of the function and it's working like a charm now. Thanks again!
  14. Again, I appreciate your help but I have been writing like this for a long time and have never had a problem before. I don't believe the problem has anything to do with syntax. It seems to me that there is some problem with the logic of the while statement or something. To prove this, I change the code to what you suggested and I have the exact same problem. Code now looks like this... function reportQuery($reportName, $accountNumber){ $rq = "SELECT * FROM " . $reportName . " WHERE AccountNum = " . $accountNumber; $retq = mysql_query($rq); echo mysql_error(); return $retq; } $query = "select * from accountinfo WHERE Paid = ''"; $rt = mysql_query($query); echo mysql_error(); while($kt = mysql_fetch_array($rt)){ echo $kt['AccountNum'] . "<br />"; echo "<table border='1' cellspacing='1' cellpadding='1'><tr><th>Type</th><th>Account Number</th><th>Employee</th><th>Pay</th></tr>"; while($rd = mysql_fetch_array(reportQuery('adjustmentsreport', $kt['AccountNum']))){ echo "<tr><td>Adjustment</td><td>" . $rd['AccountNum'] . "</td><td>" . $rd['Name'] . "</td><td>yes/no</td></tr>"; } echo "</table>"; }
  15. I appreciate your quick response but unfortunately, that did not help. Still having the same problem.
×
×
  • 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.