Welcome Guest, Not a member yet? Register   Sign In
Call to a member function validate() on a non-object using own library
#6

I fixed it but I don't like the solution! I am surprised it works this way!

PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
//Custom error handling
class Generate_token   
{
 public function 
generate()
 {
 
           $CI =& get_instance();
 
           $raw_random_bytes mcrypt_create_iv(6MCRYPT_DEV_URANDOM);
 
       $encoded_random_bytes base64_encode($raw_random_bytes);
 
       $token strtr(trim($encoded_random_bytes'='), array('+' => '-''/' => '_'));
 
           if($CI->generate_token->validate($token)==$token)
 
            {
 
            return $token;
 
            }
 
       }
 public function 
validate($token)
 {
 
$CI =& get_instance();
 
$sql "SELECT id FROM url_tokens WHERE short_url = ?";
 
       $query $CI->db->query($sql, array($token));
 
       if($query->num_rows==0)
 
           {
 
               return $token;
 
           }
 
       else
         
{
 
        $CI->generate();
 
           
 


Reply


Messages In This Thread
RE: Call to a member function validate() on a non-object using own library - by behnampmdg3 - 01-26-2015, 04:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB