Welcome Guest, Not a member yet? Register   Sign In
Active Record not showing the result UTF-8

Hello, i´m trying to get this done since yesterday, please with some one know any ideia please let me know!! thanks a lot...

I´m getting information from XML

$rss_file = 'http://psyte.uol.com.br/aspx/rss/rss.aspx?s=1';
$xml = simplexml_load_file($rss_file);

//then I define $title with title from XML, working fine.
$title = $xml->channel->item[$i]->title; // this come with value = Rave 2010

//I did this because I want to search records from database with this title

// no results

the problem is when I search from XML I can´t find any result but if I define the search manually like:

$title = 'Rave 2010';

this come with results.

this getting me crazy!!!!! please let me know with anybody have any ideia... thanks!!!!!

I have had problems like this with xml too.

Maybe you could typecast $title to (string) ???

i tried:

$title = (string)$title;

but didn´t work... i lost 3 days with this....

I have had the same problem with XML before, I never did find a way to fix it. I think this is an actual PHP bug.

I ran into the error looking at an xml return from a credit card processor and I ended up just using a different processor that returned a string rather than xml because of it.

I found this on the php.net site:

I had a problem with simplexml reading nodes from an xml file. It always return an SimpleXML-Object but not the text inside the node.

<?xml version="1.0" encoding="UTF-8"?>

Reading this xml into a variable called $xml and then doing the following
$myId = $xml->Id;
Did not return 123 in $myId, but instead I got a SimpleXMLElement Object.

The solution is simple, when you know it. Use explicit string conversion.
$myId = (string)$xml->Id;

And this..

Addition to QLeap's post:
SimpleXML will return a reference to an object containing the node value and you can't use references in session variables as there is no feasible way to restore a reference to another variable.

This won't work too:
echo $array[$val]; // will cause a warning because of the wrong index type.

You have to convert/cast to a String first:
echo $array[(string)$val];

This will work as expected, because converting will call the __toString() method. Therefor echo works too:
echo $val; // will display the name

Hell, here is a link Smile.. it appears we are not the first to come across the problem!


thanks to reply, but i saw this information at php.net before post here...

i tried everything, and didn´t work.


is it another way to do that? i need get information from XML and save that information in data base, but before that i should check if that information is in DB already.

Is it very strange because i did the method to save the information at database, the only thing i couldn´t get done is check if that information is in DB, with search query.

I was thinking about UTF-8 and ISO, but all of my pages and db are in UTF-8.

thanks again for the replys... let see if we can get this fixed....

People.. i got!!! i think.. the solution is in:http://ellislab.com/codeigniter/user-guide/general/styleguide.html#strings


Always use single quoted strings unless you need variables parsed, and in cases where you do need variables parsed, use braces to prevent greedy token parsing. You may also use double-quoted strings if the string contains single quotes, so you do not have to use escape characters.

"My String" // no variable parsing, so no use for double quotes
"My string $foo" // needs braces
'SELECT foo FROM bar WHERE baz = \'bag\'' // ugly

'My String'
"My string {$foo}"
"SELECT foo FROM bar WHERE baz = 'bag'"

you should use {}. i just used {$title} in active record.

$title = $xml->channel->item[$i]->title;

$this->forum->where("topic_title = '{$title}'");// it should be better, but this way worked

that´s it... thanks people....

Theme © iAndrew 2016 - Forum software by © MyBB