collapse collapse

* User Info

 
 
Welcome, Guest. Please login or register.
Did you miss your activation email?

* Who's Online

  • Dot Guests: 182
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Re: How to Add signature in Simple Portal? by tocnaza
[July 06, 2019, 12:04:00 PM]


Re: Yeni Sürüm Çıkacak mı? by mkuru
[July 01, 2019, 03:05:44 AM]


Re: Yeni Sürüm Çıkacak mı? by akorkut
[June 28, 2019, 05:38:26 AM]


Re: Yeni Sürüm Çıkacak mı? by mkuru
[June 26, 2019, 12:09:02 PM]


Yeni Sürüm Çıkacak mı? by akorkut
[June 25, 2019, 04:53:54 AM]

Welcome to SimplePortal.net! You can download SimplePortal from the Downloads Area!

Author Topic: Database error in block code. Please check the code.  (Read 3629 times)

0 Members and 1 Guest are viewing this topic.

Offline FireDitto

  • Jr. Member
  • **
  • Posts: 91
  • Gender: Female
    • Second Pass Weyr
  • SMF Version: 2.0.11
  • SP Version: 2.3.5
  • Elkarte Version: None
Database error in block code. Please check the code.
« on: December 13, 2012, 10:29:46 AM »
I just wanted to update an option on an already working block, and I got the following error upon saving:

Quote
An Error Has Occurred!
Database error in block code. Please check the code.

Like I said; the block is still active and working but... Won't let me update? This is the code I'm using:

Code: [Select]
$columns = 3;
$block_ids = array(9,11,39);

$block_data = array();
foreach ($block_ids as $block)
{
   $block_data[$block] = current(getBlockInfo(false, $block, false, false));
   $block_data[$block]['style'] = sportal_parse_style('explode', $block_data[$block]['style'], true);
}

echo '
<table style="width: 100%;">
   <tr>';

$counter = 0;
foreach ($block_data as $data)
{
   if ($counter != 0 && $counter % $columns == 0)
   {
      echo '
   </tr>
   <tr>';
   }

   echo '
      <td style="width: ', ceil((100 / $columns)), '%; vertical-align: top;">
         ', template_block($data), '
      </td>';

   $counter++;
}

echo '
   </tr>
</table>';

Offline phantomm

  • Translator
  • *
  • Posts: 406
  • Gender: Male
  • Smile, tomorrow will be worse...
    • Polish ElkArte community
  • SMF Version: None
  • Elkarte Version: 1.0.5
Re: Database error in block code. Please check the code.
« Reply #1 on: December 13, 2012, 12:04:30 PM »
I can't reproduce this error on my site, did you tried to disable PHP validation (SimplePortal > General Settings)?

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Database error in block code. Please check the code.
« Reply #2 on: December 14, 2012, 02:19:28 PM »

FireDitto,

  I also find that the php block saves & works as it should. Although I can think of 2 possible issue..

  • Ensure the block type you are selecting is indeed php
  • The echo command requires periods (not commas) for attributes within quotes using variables/integers

Imo try adjusting this part of the code as such:
Code: [Select]
echo '
      <td style="width: '. ceil((100 / $columns)). '%; vertical-align: top;">
         ', template_block($data), '
      </td>';

For echo you do use commas for separation but not within attribute quotations as it requires a period.

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: Database error in block code. Please check the code.
« Reply #3 on: December 14, 2012, 11:48:48 PM »

FireDitto,

  I also find that the php block saves & works as it should. Although I can think of 2 possible issue..

  • Ensure the block type you are selecting is indeed php
  • The echo command requires periods (not commas) for attributes within quotes using variables/integers

Imo try adjusting this part of the code as such:
Code: [Select]
echo '
      <td style="width: '. ceil((100 / $columns)). '%; vertical-align: top;">
         ', template_block($data), '
      </td>';

For echo you do use commas for separation but not within attribute quotations as it requires a period.

The concatenation of the strings does not matter in this case. Using either a period or a comma in the case of separating variables from output does not effect anything. If anything, all you're doing ultimately using using more concats that you should be, though this is a problem that SMF has in of itself. PHP is forced to re-concatenate with every '.' operator, so it ends up slower. Commas however fix this problem though it does end up looking rather silly.

eg;

Fast:
Code: [Select]
echo "{$str1}{$str2}{$str3}";
Slow:
Code: [Select]
echo $str1 . $str2. $str3;

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Database error in block code. Please check the code.
« Reply #4 on: December 15, 2012, 12:24:12 PM »

ccbtimewiz,

  Thank you for the proper terminology & information. Imo in this case the loop would not be large enough to notice any difference when using concat.  Please note that I am specifically referring to variables/integers being used within the style attribute quotations and not any other part of the display.

FireDitto,

  As I said, the block works for me as it is. I suggested the concat within the style quotes as I have had errors in the past using a comma where using concat solved the problem. It will not hurt to try to see if the change will allow you to save the php block code. I do not suggest disabling PHP validation as the code should validate if there are no issues/errors with it.