Topic: Strstr and Strpos using Xajax

Hey guys,

I don't know if this issue has already been discussed, but i have some problems using strstr and strpos.
Im working an a project that extracs content from files. And as i already stated strstr and strpos, just does not
do anything. Id prefer not to write my own semi strstr, strpos functions.

Im using Xajax based on the Typo3 Extention, im using the xajax Javascript Library version 0.2.5 not sure if its 0.5 or 0.2.
Eather way is there some one with a simular problem + solution, or has a workaround laying around.

Thnx for the help in advance,
Kind regards,

Sebastiaan van Parijs

Re: Strstr and Strpos using Xajax

Hi,

Please post some code.

strstr and strpos are simple PHP functions and have nothing to do with XAJAX.

Ed

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.

Re: Strstr and Strpos using Xajax

Obviously strstr and strpos are standerd php functions, the only problem is that they
don't work or randomly work.....

Code: PHP

$sources  = array( 0, 'bla bla x bla bla y',

                              1, 'bla bla bla bla ',

                              3, 'bla bla x bla bla y' );



$content = new content();



$points = array( 'x','y' );



foreach ( $sources as $source ) {



  $test[] =  ( $content-> sourceContains( $source, $points ) ? 'TRUE item found' : 'FALSE item not found' );



}



$content = implode( chr(10), $test);



$objResponse = new tx_xajax_response();

   

$objResponse->addAssign('debug', 'innerHTML', $content );

               



return $objResponse->getXML();



class content {





    function sourceContains( $source, $points ){

   

        // I look for elements in the Source if they are there its true else false.

        foreach ( $points as $point ){

            if ( strstr( $source, $point ) ){

                       

               

                return true;

            }

        }

   

        return false;

    }



}

 

*Note that i use strstr and strpos multiple times. I not only check if they are there but extract them aswell with strstr and strpos.

Ive seen 1 function get a true return value an other false with the same conditions and content......
So my 6 hour debug run concludes its a xajax problem i have seen 1 simular post on some other php forum with the same issue.

Hope u can use my code.

Thnx for the quick responce btw. smile

Sebastiaan

Last edited by svanparijs (2010-03-04 10:08:23 AM)

Re: Strstr and Strpos using Xajax

Something that might help with a quick function, i got from PHP Net

Code: PHP

$email  = 'name@example.com';



$user = strstr($email, '@', true); // As of PHP 5.3.0

$user; // prints name



$objResponse = new tx_xajax_response();



$objResponse->addAssign('debug', 'innerHTML', $user );



return $objResponse->getXML();

 

When i use this function it doesnt work..... it returns NOTHING.

Please help, its the last bug of my project.

Last edited by svanparijs (2010-03-04 11:30:46 AM)

Re: Strstr and Strpos using Xajax

Sebastiaan,

Here is a sample XAJAX'ed page that works using strstr();

Code: PHP

<?php

include_once("xajax/xajax_core/xajax.inc.php");

$xajax = new xajax();

$xajax->configure('debug',true);

$xajax->configure('javascript URI', 'xajax/');



function test()

{

  $resp = new xajaxResponse();

  $email = 'mymail@someprovider.com';

  $domain = strstr($email, '@');

  $resp->assign("user","innerHTML",$domain);

  return $resp;

}



$xajax->register(XAJAX_FUNCTION,"test");

$xajax->processRequest();

?>

<html>

<head>

<?php $xajax->printJavascript();?>

</head>

<body>

<input type="button" value="Test" onclick="xajax_test()">

<div id="user"></div>

</body>

</html>

 

I fear you are missing some detail of the setup of the XAJAX stuff... smile

Ed

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.

Re: Strstr and Strpos using Xajax

Im working on getting Xajax 0.5 working in my Typo3 Site so, ill give it a go as soon as i have it up and running.
Figured i was wasting my time anyway with 0.2.

Re: Strstr and Strpos using Xajax

Sebastiaan,

You're not wasting your time with V0.2 - you could do the same thing with a little different syntax - but 0.5 is a much better choice...

Ed

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.

Re: Strstr and Strpos using Xajax

Hi Ed,

Well i finally got v0.5 up and running,and it seems i've got strstr and strpos back in business. I dont understand why it works now and didnt before. But ill do some more testing, for now tnx for the sample and the quick replys.

Sebastiaan