Jump to content

MYSQL cell + Line break... how to find them with php?


ltrem

Recommended Posts

Hey guys,  I have a cell that is filled with alot of text. At some point in the text, there is a line break in the MYSQL CELL that I just can't find after I retreive the value in my php code.... heres a little sample of the value in the cell.

 

habitable et de coûts de construction.<br /><br />
Vous avez trouvé la maison

 

There is absolutely nothing between the > and the Vous...

 

Thanks alot !

 

PS. I tried

					if(strpos($searchDesc, '\n' )){ // I tried '\r\n' too...
					echo 'yes, its found';
				}else{
					echo 'not found';
				}

 

while $searchDesc is the concerned cell

Do you use nl2br and htmlentities or htmlspecialchars somewhere? because it looks like you first you nl2br and then escape the html

 

First of all, I retrieve a cell from the DB that is XML content, from that XML, I retrieve the value I need. Then I do a html_entity_decode() AND strip_tags() to finally insert it in another MYSQL Table.

 

Now is the problem, when I retrieve that same value I just inserted, I can't separate the Line Break...

Bit of code to get the XML

 

$searchDesc = $xml_arrVal['searchtext']; //retrieve the XML value I need

if(strpos($searchDesc, "<br />" )){
echo 'yes, its found';
}else{
echo 'not found';
}

 

and the $xml_arrVal['searchtext']; =

<field index="searchtext">
                    <value index="vDEF">blablabla ....À vous d'y attribuer le rôle désiré !<br /><br />
Vous avez trouvé la maison de style...blablabla</value>
                </field>

 

And maybe you might want this.. the head of the XML

 

<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<T3FlexForms>
    <data>
        <sheet index="sDEF">
            <language index="lDEF">

well firstly, strpos doesn't return a boolean value unless its false, it returns an integer value, so that might be what is causing problems.

 

try something like

if (strpos($searchDesc, "stuff") === false){
echo "Fail";
}
else {
echo "Success!";
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.