在我自己的脚本中使用jimport

When i try to use jimport('joomla.user.helper') it gives me this error.

Fatal error: Call to undefined function jimport() in /home/joomclan/public_html/quiz/pop_fetching.php on line 223

This is my code where i use this:

 function addJoomlaUser($name, $username, $password, $email) {
  jimport('joomla.user.helper');
  $salt   = JUserHelper::genRandomPassword(32);
  $crypted  = JUserHelper::getCryptedPassword($password, $salt);
  $cpassword = $crypted.':'.$salt;

  $data = array(
      "name"=>$name,
      "username"=>$username,
      "password"=>$password,
      "password2"=>$password,
      "email"=>$email,
      "block"=>0,
      "groups"=>array("1","2")
  );

add at the top

include(JPATH_BASE.'libraries/loader.php')

but, afraid, something wrong with your code

http://www.webdeveloper.com/forum/showthread.php?226904-jimport-in-Joomla-how-does-it-work

It's defined in "libraries/loader.php", which is included by "libraries/joomla/import.php", which is included by "includes/framework.php", which is included by "index.php" (all paths relative to the base Joomla directory).

Probably this will be helpful as well jimport not working in Joomla 1.5

in your script, at the top, initialise joomla framework as below.

`define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$app =& JFactory::getApplication('site');
$app->initialise();
jimport( 'joomla.user.user' );`

I always use that.