Block adds on laptop but doesn't add on host - SOLVED

Permalink
Hello,

I've designed a block for Concrete5 - a contact form. It takes 3 variables as user input during block installation (e.g. email address to send the form to). It installs fine on both my laptop's server and host's. When I try to add the block on my own server running on my laptop, it adds just fine. When I add it on my real hosting provider's server, it gives me the following error: "An unexpected error occurred. An error occurred while processing this request.< Back to Home".

I can't even imagine where to look to figure out what the problem could be. Anyone have any ideas? Thank you.

[SOLVED]
It turned out to be a trivial error. And Concrete5's Reports->Logs tool is pretty useful, I didn't know it was in the Panel, I found it accidentally. What happened was my block creates a DB table and takes some values from it in view(). But the thing was I've already created the table on my laptop long time ago, and when I was playing with installing/uninstalling, adding/deleting my block, everything was working fine. But on my host the table was not created. And the error was my block tried to read the table BEFORE it was created, but it only got created after the block gets added to a page! So, when I saw the log showing DB errors accessing the non-existent table... oh my...

Hope my experience helps someone. Remember about the Log feature!

add.php:
<?php defined('C5_EXECUTE') or die("Access Denied.");
$email_address = '';
$email_subject = '';
$submit_wait_time = '';
include_once('edit.php');
?>


edit.php:
<?php defined('C5_EXECUTE') or die("Access Denied.");?>
<style type="text/css" media="screen">
   .ccm-block-field-group h2, h3 { margin-bottom: 5px; }
</style>
<div class="ccm-block-field-group">
   <h2>Form Configuration</h2>
   <div class="ccm-block-field-group">
      <h3>Email Address</h3>
      <input type="text" id="email_address" name="email_address" value="<?php  echo  $email_address; ?>" maxlength="100" size="30" />
   </div>
   <div class="ccm-block-field-group">
      <h3>Email Subject</h3>
      <input type="text" id="email_subject" name="email_subject" value="<?php  echo  $email_subject; ?>" maxlength="100" size="30" />
   </div>
   <div class="ccm-block-field-group">


controller.php:
public function on_page_view() {
      $this->set('email_address', $this->email_address);
      $this->set('email_subject', $this->email_subject);
      $this->set('submit_wait_time', $this->submit_wait_time);
   }
   public function save($data) {
      $args['email_address'] = ($data['email_address'] != '') ? $data['email_address'] : '';
      $args['email_subject'] = ($data['email_subject'] != '') ? $data['email_subject'] : '';
      $args['submit_wait_time'] = (intval($data['submit_wait_time']) > 0) ? intval($data['submit_wait_time']) : 60;
      parent::save($args);
   }

linuxoid
 
JohntheFish replied on at Permalink Reply
JohntheFish
I am guessing the controller code is just a snippet, as it certainly isn't an entire block controller.

Some things to double check:
- case sensitivity of file names
- case sensitivity of database table and column names
- compatible versions of PHP
linuxoid replied on at Permalink Reply
linuxoid
JohntheFish,

Yes, the controller snippet is just for the save() function.

The thing is it installs and adds perfectly fine on my own server, but not on host.

This is the db.xml:
?xml version="1.0"?>
<schema version="0.3">
   <table name="AbContactForm">
      <opt platform="MYSQL">ENGINE=MYISAM</opt>
      <field name="bID" type="I">
         <key ></key>
         <unsigned ></unsigned>
      </field>
      <field name="email_address" type="C" size="200">
      </field>
      <field name="email_subject" type="C" size="200">
      </field>
      <field name="submit_wait_time" type="I">
         <unsigned ></unsigned>
         <default value="60" ></default>


I also noticed something weird: on my own server, where it all works fine, when I add my block I enter some values into the form, save it, the block adds, when I edit it, the values I entered are taken from the database. I checked the database, they are indeed there. So all is fine. But when I add the block on the host's server, first it gives me the error. I then entered some values into the database manually through PhpMyAdmin. But when I add the block, the form is empty, seems like it doesn't take anything from the database. How is it so? It gets values from the DB on my server, but not on my host's? The site and all other blocks work just fine. It's only my block. And I can't figure out what it is.
JohntheFish replied on at Permalink Reply
JohntheFish
Some environments have case sensitive db. Some have case invariant db. (EDIT) Some have different default db tables.
Same with file systems.
Also different php versions between environments support different language features.

So you could develop with any of the above, get away with a small bug not showing, then bump in to it when you move to a different environment.

Hence my checklist above.