Database error when adding department

Hi, i successfuly setup a new instance of gibbon v.19 on windows 7. When i add department the first department adds successfully. But on trying to add a second department i get the error “Your request failed due to a database error.”. I am able to add other items like staff, users, year groups etc with no issue so far. Installation is set to production and cutting edge is set to No. Please help

Hi ajumba, I’m sorry to hear about this issue. I’ve tried to recreate it in a fresh install of v19, but cannot. In order to learn more, can you please open /modules/School Admin/department_manage_addProcess.php in a text editor, and find the three lines that say:

$URL .= ‘&return=error2’;

If you add an a, b and c to each of these in turn, e.g:

$URL .= ‘&return=error2a’;
$URL .= ‘&return=error2b’;
$URL .= ‘&return=error2c’;

And then rerun the addition, you’ll be able to see, from the URL that is returned, which line caused the error. Let us know the line number, and we can start to offer further things to check to find the difference between our install and your install.



Hi, on making these changes i get the error “Unknown return” and i get this URL on the encountering the error:


in the php file this is on line 131.

rgds Antony

Hi Antony,

It looks like this script may not be checking uniqueness for name or nameShort. Any chance you’re using the name name or short name when you’re creating the second department? That’s one possible scenario that would return the error you’re seeing.

Hi Sandra,

I tried different names and name combinations. The first dept saves OK but after that it runs into the db error.

I even deleted the dept I created successfully and created a new one then used the names I had used successfully the first time and still got the error.

Hi Antony, OK, let’s try and see exactly what error is being produced. Can you please remove the contents of lines 128-130, and replace them with this:

echo $e->getMessage(); exit;

You should get a plain white screen with an SQL error. Share that error with us. Thanks!

Hi, thanks for your kind assistance. However i did get a workaround… when i examined the table in mysql i found that for some reason default values were required for the:

  1. Subject Listing - i put a default value of ‘0000’
  2. Blurb - i put in a NULL default value
  3. Logo - i put in a default value ‘test’

I have attached a screenshot to show this.

After this it now works well and i can departments with no errors.

However i am not sure what the root cause of the issue was…

Hi Antony, that is very odd indeed. These fields do not allow NULL, but they can be set to empty, and so the process PHP script receiving a blank value should not cause this issue. Are you able to share the SQL error described above? Thanks, Ross.

Hi Ross, which sql error would you like me to share ? The original error ?

The one you see on screen if you remove the contents of lines 128-130, and replace them with this:

echo $e->getMessage(); exit;

Cheers, Ross.