Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 7th, 2013, 5:17 PM   #11
origamiguy
Programmer
 
Join Date: Jan 2013
Posts: 55
Rep Power: 5 origamiguy is on a distinguished road
Re: updating mysql records

ok so i have the following code and just need help understanding whats wrong.
$filter_query = "SELECT FileName AS file, Filter AS filter From Filter";
	
	if($fq = mysqli_query($conn,$filter_query))
	{
		while($f = mysqli_fetch_array($fq,MYSQL_ASSOC))
		{
			$file = file_get_contents("company\\" . rtrim($f["file"],'.gz'));
			$filter = explode(",",$f["filter"]);
			$xml = new SimpleXMLIterator($file);
			foreach ($xml->children() as $second_gen){
				if($second_gen->count() > 0)
				{
					$i = 0;
					foreach($second_gen->children() as $child)
					{
						switch($filter[$i])
						{
							case 'remove':
								break;
							case 'keep':
								echo $child . "<br>";
								break;
							default:
								echo $child . " was changed to $filter[$i] <br>";
						}
						$i++;
					}
					echo "<hr>";
					break;
				}
			}
			unset($xml);
			unset($file);
			unset($filter);

		}
	}

the errors:

Warning: SimpleXMLElement::__construct(): Entity: line 46223: parser error : PCDATA invalid Char value 3 in C:\xampp\htdocs\NewSite\update.php on line 88

Warning: SimpleXMLElement::__construct(): r metabolism and say â€Å“NOâ€? to pesky cravings once and for all. in C:\xampp\htdocs\NewSite\update.php on line 88

Warning: SimpleXMLElement::__construct(): ^ in C:\xampp\htdocs\NewSite\update.php on line 88

Warning: SimpleXMLElement::__construct(): Entity: line 56336: parser error : PCDATA invalid Char value 30 in C:\xampp\htdocs\NewSite\update.php on line 88

Warning: SimpleXMLElement::__construct(): ine Monohydrate and Creatine HCl developed with pH-Sorbâ„¢, a unique pH buff in C:\xampp\htdocs\NewSite\update.php on line 88

Warning: SimpleXMLElement::__construct(): ^ in C:\xampp\htdocs\NewSite\update.php on line 88

Warning: SimpleXMLElement::__construct(): Entity: line 57595: parser error : PCDATA invalid Char value 3 in C:\xampp\htdocs\NewSite\update.php on line 88

Warning: SimpleXMLElement::__construct(): <description>A powerful drug-free formula designed to "dry" out excess in C:\xampp\htdocs\NewSite\update.php on line 88

Warning: SimpleXMLElement::__construct(): ^ in C:\xampp\htdocs\NewSite\update.php on line 88

Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in C:\xampp\htdocs\NewSite\update.php:88 Stack trace: #0 C:\xampp\htdocs\NewSite\update.php(88): SimpleXMLElement->__construct('<?xml version="...') #1 {main} thrown in C:\xampp\htdocs\NewSite\update.php on line 88

i am still trying to look through it but if you know by looking the help would be appreciated. thanks
origamiguy is offline   Reply With Quote
Old Sep 7th, 2013, 5:45 PM   #12
pritaeas
mod_pritaeas
 
Join Date: May 2009
Location: The Netherlands
Posts: 251
Rep Power: 8 pritaeas is on a distinguished road
Re: updating mysql records

There's something wrong with your XML. Can you post it?
pritaeas is offline   Reply With Quote
Old Sep 7th, 2013, 5:58 PM   #13
origamiguy
Programmer
 
Join Date: Jan 2013
Posts: 55
Rep Power: 5 origamiguy is on a distinguished road
Re: updating mysql records

i believe the files are over the limit to attach and i don't the program goes through all the files by itself so i don't know which it is?

can you tell what the problem is?
origamiguy is offline   Reply With Quote
Old Sep 7th, 2013, 6:29 PM   #14
pritaeas
mod_pritaeas
 
Join Date: May 2009
Location: The Netherlands
Posts: 251
Rep Power: 8 pritaeas is on a distinguished road
Re: updating mysql records

Looks like character encoding issue.
pritaeas is offline   Reply With Quote
Old Sep 7th, 2013, 6:56 PM   #15
origamiguy
Programmer
 
Join Date: Jan 2013
Posts: 55
Rep Power: 5 origamiguy is on a distinguished road
Re: updating mysql records

how do you fix it? ummm let me try to see if i can find what file(s) are bugging out.
origamiguy is offline   Reply With Quote
Old Sep 7th, 2013, 7:05 PM   #16
origamiguy
Programmer
 
Join Date: Jan 2013
Posts: 55
Rep Power: 5 origamiguy is on a distinguished road
Re: updating mysql records

i found the file and here is a line

With FitMiss Burn™ on your side you can kick-start your metabolism and say “NO� to pesky cravings once and for all. Stay focused while annoying fat simply vanishes.*

i think i know the character's it doesnt like.lol
origamiguy is offline   Reply With Quote
Old Sep 7th, 2013, 10:08 PM   #17
origamiguy
Programmer
 
Join Date: Jan 2013
Posts: 55
Rep Power: 5 origamiguy is on a distinguished road
Re: updating mysql records

is there a way to have the "$xml = new SimpleXMLIterator($file);" skip over bad entries?
or at the very least let the program keep running after a file is found to be "bad"
origamiguy is offline   Reply With Quote
Old Sep 8th, 2013, 3:13 AM   #18
pritaeas
mod_pritaeas
 
Join Date: May 2009
Location: The Netherlands
Posts: 251
Rep Power: 8 pritaeas is on a distinguished road
Re: updating mysql records

Is the database and xml file in utf8?

Am not sure, I know it has a valid() method, so you could check perhaps.
pritaeas is offline   Reply With Quote
Old Sep 8th, 2013, 9:48 AM   #19
origamiguy
Programmer
 
Join Date: Jan 2013
Posts: 55
Rep Power: 5 origamiguy is on a distinguished road
Re: updating mysql records

the script is breaking at "$xml = new SimpleXMLIterator($file);" . it breaks while trying to read it in. so it never actually makes the object. how do you use valid if it stops at this line?

EDIT::: i tried this but it bugs out.

$test = mb_check_encoding($file,"UTF-8");
if($test)
print "LOOKS GOOD <br>";
else
print "LOOKS BAD <br>";

Last edited by origamiguy; Sep 8th, 2013 at 10:01 AM.
origamiguy is offline   Reply With Quote
Old Sep 8th, 2013, 11:09 AM   #20
pritaeas
mod_pritaeas
 
Join Date: May 2009
Location: The Netherlands
Posts: 251
Rep Power: 8 pritaeas is on a distinguished road
Re: updating mysql records

If you try to load the XML into SimpleXML or into DOMDocument, does that give you the same error?
pritaeas is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
awk - counting number of records and updating heading laperlenoire@gmail.com Sed and Awk 8 Dec 24th, 2012 5:43 AM
php mysql bulk records update? phantoma2 PHP 4 Feb 11th, 2012 10:10 AM
"Forbidden Page" while updating MYSQL using PHP chibib0 PHP 1 Jan 18th, 2009 1:56 AM
mysql get last 10 records in a table kruptof Other Web Development Languages 3 Jun 29th, 2007 10:23 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:57 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC