Categories > TinyButStrong general >

TbsSql and TBS 3.2

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Trent
Date: 2007-01-08
Time: 05:33

TbsSql and TBS 3.2

I'm using TbsSql 1.01 (or 1.1??) and TBS v. 3.2 and I'm having problems outputting data to my template.  Here is my php code:

//Stats.php
include('tbssql_mysql.php');
include('tbs_class.php');
$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate('stats.html') ;
$TBS->MergeBlock('users','tbssql','SELECT * FROM users where id = 1');
$TBS->Show() ;

When I run stats.php, I get the following error:

TinyButStrong Error when merging block [users] : Data source Id 'tbssql' is unsupported because function 'tbsdb_tbssql_open' is not found.

Can someone point me in the right direction here?
By: Skrol29
Date: 2007-01-08
Time: 19:23

Re: TbsSql and TBS 3.2

Hi Trent,

An instance of TbsSQL is missing, and probably the opened connection to the database.

To open a MySQL connection:
$Db = new clsTbsSQL('server','uid','pwd','database');

If you already have an opened MySQL connection:
$Db = new clsTbsSQL; // MySQL and PostgreSQL can use the last opened connection without a hook
By: Trent
Date: 2007-01-08
Time: 20:32

Re: TbsSql and TBS 3.2

Thanks.  That did it.  I can't believe I overlooked that.
By: Don Bledsoe
Date: 2007-05-09
Time: 13:41

Re: TbsSql and TBS 3.2

I've missed something here, but cannot see it is.

PHP:
include_once('includes/tbssql_mysql.php');
$Db = new clsTbsSQL('localhost', 'forefron_forefro', 'PASSWORD', 'forefron_domtrak');
$Db->Mode = 2;

include_once('includes/tbs_class.php');
$TBS = new clsTinyButStrong;

$TBS->LoadTemplate('tpl/view.tpl.html');
$TBS->MergeBlock('blk','tbssql','SELECT * FROM domains ORDER BY domain');

$TBS->Show();

HTML:
    <TABLE class=format>
        <TR>
        <TD class=idwidth><P class=idnum><BR>ID</P></TD>
        <TD class=namewidth><P class=name>CUSTOMER NAME<BR>COMPANY</P></TD>
        <TD class=accountwidth><P class=account>ACCOUNT<BR>NUMBER</P></TD>
        <TD class=domainwidth><P class=domain>DOMAIN<BR>NAME<BR></P></TD>
        <TD class=expireswidth><P class=expires>EXPIRES<BR>CREATED</P></TD>
        <TD class=emailwidth><P class=email>EMAIL<BR>ADDRESS</P></TD>
        <TD class=hostingwidth><P class=hosting>WHERE<BR>HOSTED<BR></P></TD>
        </TR><TR>
        <TD class=dataC>[blk.id;block=tr]</TD><TD class=dataL>[blk.custLname;block=tr], [blk.custFname;block=tr]<BR>[blk.company;block=tr]</TD>
        <TD class=dataC>[blk.account;block=tr]</TD><TD class=dataR>[blk.domain;block=tr]</TD>
        <TD class=dataC>[blk.expiresdate;block=tr]<BR>[blk.createdate;block=tr]</TD>
        <TD class=dataR>[blk.email;block=tr]</TD>
        <TD class=dataC>[blk.hosted;block=tr]</TD>
        </TR>
    </TABLE>
I think I'm doing something fundamentally wrong, but don't know what it is.
By: Skrol29
Date: 2007-05-10
Time: 00:44

Re: TbsSql and TBS 3.2

Hi,

Parameter "block" is case sensitive.
It should be [blk.id;block=TR].
And you need only one "block=TR" in one field of the block. Others are superfluous and ignored.
By: Don Bledsoe
Date: 2007-05-10
Time: 02:44

Re: TbsSql and TBS 3.2

Thanks for the clarification. I'm getting this error:

TinyButStrong Error when merging block [blk] : Data source Id 'tbssql' is unsupported because function 'tbsdb_tbssql_open' is not found.

I thought this was because the class is not being instantiated, but I think it is, unless there's an error in my syntax or some other detail I've overlooked.
By: Skrol29
Date: 2007-05-10
Time: 03:14

Re: TbsSql and TBS 3.2

Hi,

Your message should not be displayed since your have instancied TbsSQL before the MergeBlock() with a $Db = new clsTbSQL(...);

Are you sure TbsSQL is instanced before you call MergeBlock() ?
If it's so, can you test the existence of the variable $GLOBALS['_TBS_UserFctLst']['k:tbssql'] just before the MergeBlock ?
By: Don Bledsoe
Date: 2007-05-10
Time: 04:05

Re: TbsSql and TBS 3.2

Okay, I tested it with this:
include_once('includes/tbssql_mysql.php');
$Db = new clsTbsSQL('localhost', 'forefron_forefro', 'PASSWORD', 'forefron_domtrak');
$Db->Mode = 2;

include_once('includes/tbs_class.php');
$TBS = new clsTinyButStrong;

$TBS->LoadTemplate('tpl/view.tpl.html');

if (isset($GLOBALS['_TBS_UserFctLst']['k:tbssql'])) {
    $TBS->MergeBlock('blk','tbssql','SELECT * FROM domains ORDER BY domain');
    $TBS->Show();
} else {
    echo "GLOBALS do not exist.\n\r";
}
I don't know what I'm doing wrong.
By: Don Bledsoe
Date: 2007-05-10
Time: 04:06

Re: TbsSql and TBS 3.2

Duh ... it reports: GLOBALS do not exist.
By: Skrol29
Date: 2007-05-10
Time: 10:20

Re: TbsSql and TBS 3.2

Ok,

This is strange because this value is set by the creator function of the TbSQL class.
Can you double check the version of TbsSQL ?
Can you aslo do the same test of variable existence just after the line $Db = new clsTbsSQL(...) ?
By: Don Bledsoe
Date: 2007-05-10
Time: 12:18

Re: TbsSql and TBS 3.2

Here's what I ran:
include_once('includes/tbssql_mysql.php');
$Db = new clsTbsSQL('localhost', 'forefron_forefro', 'Zipp1ttY', 'forefron_domtrak');

if (isset($GLOBALS['_TBS_UserFctLst']['k:tbssql'])) {
    echo "Check after clsTbsSQL: GLOBALS exist.\n\r";
} else {
    echo "Check after clsTbsSQL: GLOBALS do not exist.\n\r";
}

$Db->Mode = 2;

include_once('includes/tbs_class.php');
$TBS = new clsTinyButStrong;

if (isset($GLOBALS['_TBS_UserFctLst']['k:tbssql'])) {
    echo "Check after clsTinyButStrong: GLOBALS exist.\n\r";
} else {
    echo "Check after clsTinyButStrong: GLOBALS do not exist.\n\r";
}

$TBS->LoadTemplate('tpl/view.tpl.html');

$TBS->MergeBlock('blk','tbssql','SELECT * FROM domains ORDER BY domain');
$TBS->Show();
Results:
Check after clsTbsSQL: GLOBALS exist. Check after clsTinyButStrong: GLOBALS do not exist.
By: Don Bledsoe
Date: 2007-05-10
Time: 12:19

Re: TbsSql and TBS 3.2

Version info: Version 2.0, 2007-03-01, Skrol29
By: Skrol29
Date: 2007-05-11
Time: 11:31

Re: TbsSql and TBS 3.2

Hello,

I cannot reproduce your bug.
Can send to me a small set of files stand alone which reproduce your bug ?
By: Don Bledsoe
Date: 2007-05-14
Time: 02:00

Re: TbsSql and TBS 3.2

In case it's a help, here's a link for the PHP configuration:
http://www.forefrontinternet.com/phpinfo.php

Don
By: Don Bledsoe
Date: 2007-05-15
Time: 17:59

Re: TbsSql and TBS 3.2

Is there a recommended workaround for this until it is resolved?
By: Skrol29
Date: 2007-05-15
Time: 20:21

Re: TbsSql and TBS 3.2

Hi,

I need a snippet from you to reproduce the problem.
You configuration page doesn't give enough clues.

You problem is not normal: you are using TbsSQL a common way but you have a bug not met since now.
By: Don Bledsoe
Date: 2007-05-16
Time: 02:25

Re: TbsSql and TBS 3.2

This code works and it adds records as it is supposed to:
include_once('includes/tbssql_mysql.php');
$Db = new clsTbsSQL('localhost', 'forefron_forefro', 'Zipp1ttY', 'forefron_domtrak');

if (isset($GLOBALS['_TBS_UserFctLst']['k:tbssql'])) {
    echo "Check after clsTbsSQL: Globals exist.\n\r";
} else {
    echo "Check after clsTbsSQL: Globals do NOT exist.\n\r";
}

$Db->Mode = 0;

include_once('includes/tbs_class.php');
$TBS = new clsTinyButStrong;

if (isset($GLOBALS['_TBS_UserFctLst']['k:tbssql'])) {
    echo "Check after clsTinyButStrong: Globals exist.\n\r";
} else {
    echo "Check after clsTinyButStrong: Globals do NOT exist.\n\r";
}

if(isset($HTTP_POST_VARS['submit'])) {
    //    UPDATE record
    $lastname    = addslashes($HTTP_POST_VARS['LastName']);
    $firstname    = addslashes($HTTP_POST_VARS['FirstName']);
    $company    = addslashes($HTTP_POST_VARS['Company']);
    $email        = addslashes($HTTP_POST_VARS['Email']);
    $account    = $HTTP_POST_VARS['Account'];
    $expires    = $HTTP_POST_VARS['DomainExpires'];
    $created    = $HTTP_POST_VARS['DomainCreated'];
    $domain        = $HTTP_POST_VARS['DomainName'];
    $hosted        = strtoupper($HTTP_POST_VARS['Hosted']);
   
    $Db->Execute('INSERT INTO domains (custLname,custFname,company,email,account,expiresdate,createdate,domain,hosted) VALUES (@1@,@2@,@3@,@4@,@5@,@6@,@7@,@8@,@9@)',$lastname,$firstname,$company,$email,$account,$expires,$created,$domain,$hosted);
    $TBS->LoadTemplate('tpl/add.tpl.html');
    $TBS->Show();
}
else {
    $TBS->LoadTemplate('tpl/add.tpl.html');
    $TBS->Show();
}
I added the isset snippet you gave me and it reports:
Check after clsTbsSQL: Globals exist. Check after clsTinyButStrong: Globals do NOT exist.
But it adds records just fine, which I verified with phpMyAdmin.
By: Skrol29
Date: 2007-05-18
Time: 04:14

Re: TbsSql and TBS 3.2

Hi Don,

I've tested your snippet on PHP 4.4.5 and I have the following display:
Check after clsTbsSQL: Globals exist. Check after clsTinyButStrong: Globals exist.

So it run ok here. Can you give me your email so I can send my text to you? Then we can finally found what's going bad.
By: Don Bledsoe
Date: 2007-05-18
Time: 04:50

Re: TbsSql and TBS 3.2

Sure ... dbledsoe@forefrontinternet.com
By: Don Bledsoe
Date: 2007-05-18
Time: 05:07

Re: TbsSql and TBS 3.2

I'm running on PHP 4.4.6