Categories > TinyButStrong general >

stripslashes with MySQL?

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: brildrager
Date: 2004-03-11
Time: 17:15

stripslashes with MySQL?

I have the following php-script:
$tpl->MergeBlock('nieuws', $connect, 'SELECT * FROM nieuws ORDER BY id desc LIMIT 0, 10');

this is the template:
<table>
            <tr>
                <h1>
                    [nieuws.kop;block=table;htmlconv=no]
                </h1>
            </tr>
            <tr>
                <h2>
                    [nieuws.bericht;block=table;htmlconv=no]
                </h2>
            </tr>
        </table>

My question is: How can I use the function stripslashes(); ?
Is it possible to do it immediatly or must I store it first in a Array?
By: Skrol29
Date: 2004-03-11
Time: 17:23

Re: stripslashes with MySQL?

You need to stripslashes some MySQL fields before to display them ?
You can use the parameter 'onsection' or 'on format' to define a custom function that will arrange the data before to display them.

By the way: no need to reapeat 'block=table' for TBS fileds that are in the same block. Only one is enougth.

By: brildrager
Date: 2004-03-11
Time: 17:42

Re: stripslashes with MySQL?

I have a field 'bericht',  normally I use stripslashes(); to delete te slashes.
I try to use onscection. But how, now I have this:
[nieuws.bericht;block=table;htmlconv=no;onsection=stripslashes]

But this doesn't work. How must I use it?
By: Skrol29
Date: 2004-03-11
Time: 17:52

Re: stripslashes with MySQL?

Read the doc :)

Parameter 'onsection' must point on a custom function with a special syntax defined in the doc.
stripslashes() should be coded inside the custom function.
By: brildrager
Date: 2004-03-11
Time: 21:13

Re: stripslashes with MySQL?

O.K.
But how must I call the variable?
The block calls 'nieuws' and the field 'bericht'
maybe so?
$nieuws['bericht'] = $nieuws['bericht']
return $nieuws['bericht']
or
$RowData['bericht'] = $RowData['bericht']
return $RowData['bericht']
By: Skrol29
Date: 2004-03-12
Time: 12:46

Re: stripslashes with MySQL?

They are examples both in the manual and in the examples set.

HTML:
[nieuws.bericht;block=table;htmlconv=no;onsection=my_strip]

PHP:
function my_strip ($BlockName,&$CurrRec,&$DetailSrc,$RecNum){
  $CurrRec['bericht']=stripslashes($CurrRec['bericht']);
}
By: brildrager
Date: 2004-03-13
Time: 14:35

Re: stripslashes with MySQL?

It doesn't work I have this code
HTML:
[nieuws.bericht;block=table;htmlconv=no;onsection=strip;]
PHP;
function strip ($BlockName,&$CurrRec,&$DetailSrc,$RecNum)
{
    $CurrRec['bericht'] = stripslashes($CurrRec['bericht']);
   
    return ($CurrRec['bericht']);
}
By: Jorge
Date: 2004-03-16
Time: 14:17

Solution

Hi,

I had same problem before, solution is on:
http://www.tinybutstrong.com/index.php?page=forum&msg_id=697

By the way you can check also
http://www.tinybutstrong.com/index.php?page=forum&msg_id=926
and
http://www.tinybutstrong.com/index.php?page=forum&msg_id=872

for more info if you're problem doesn't match

Jorge

By: Brildrager
Date: 2004-03-16
Time: 17:13

Re: stripslashes with MySQL?

It works! Many thanks, this was the only thing that doestn't work on this
template-engine. I like this engine, it was the first where the Blocks just work!
I've tryed, Yapter, Powertemplate, FastTemplate and Smarty and they were
to difficult or the blocks don't work. My compliments!