• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error number: 1048, Problem using the Captcha Helper

Dear user,

I just tried to implement the captcha helper to a contact formular. The Captcha Helper will be loaded automatically.

Link to Captcha Helper, User Guide

Step 1: (controller document)
public function __construct() {

Step 2: (contact document - default content (if no submit button has been pressed))
   $vals = array(
    'img_path' => './captcha/',
    'img_url' => 'http://example.com/captcha/'

   $cap = create_captcha($vals);

   $data = array(
    'captcha_time' => $cap['time'],
    'ip_address' => $this->input->ip_address(),
    'word' => $cap['word']

   $query = $this->db->insert_string('captcha', $data);

   echo 'Submit the word you see below:';
   echo $cap['image'];
   echo '<input type="text" name="captcha" value="" />';

Step 3: (contact document - (if a submit has been pressed))
if ($this->input->post('contact-submit', TRUE) == true) {
$valid_formular = true;


// First, delete old captchas
$expiration = time()-7200; // Two hour limit
$this->db->query("DELETE FROM captcha WHERE captcha_time < ".$expiration);

// Then see if a captcha exists:
$sql = "SELECT COUNT(*) AS count FROM captcha WHERE word = ? AND ip_address = ? AND captcha_time > ?";
$binds = array($_POST['captcha'], $this->input->ip_address(), $expiration);
$query = $this->db->query($sql, $binds);
$row = $query->row();

if ($row->count == 0) {
  echo "You must submit the word that appears in the image";

Well, I did everything they told me in the User Guide and I receive following Error Message:
Quote:Error Number: 1048

Column 'captcha_time' cannot be null

INSERT INTO `captcha` (`captcha_time`, `ip_address`, `word`) VALUES (NULL, '', NULL)

Filename: C:\xampp\htdocs\portal\system\database\DB_driver.php

Line Number: 330

I know there're missing strings but I got no clue how to fix this problem since I copyied everything from the user guide, as I told already.

If you have a link to a page on it my issue been solved already, it's enough. I only found one in this board with the same issue but it didn't help me.. That's why I decided to create a new topic.

With best regards,

The create_captcha() could not create the captcha image using your parameters

$vals = array(
    'img_path' => './captcha/',
    'img_url' => 'http://example.com/captcha/'

To solve this:

1) make a directory inside codeigniter root name 'captcha' and writeable by all (or only by your web server)
2) change 'example.com' from 'http://example.com/captcha/' to your site (localhost?)

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.