Categories > TinyButStrong general >

Merge block error

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Radeon
Date: 2004-07-31
Time: 02:56

Merge block error

Well, it's me again, i've been trying out stuff with TBS all day now and it's been working pretty well untill now. I just started integrating TBS to th eproject i'm doing and i get this error: TinyButStrong Error (MergeBlock [blk1]): Unsupported variable type : 'NULL'.

I do exactly the same as i did in another test that worked but now it won't.

Database file:
<?PHP

     //-- mySQL info

     $mysqlhost = "localhost";
     $username = "root";
     $password = "lu69";
     $database = "wms_dev";

     //-- Database Connection

     $db = mysql_connect('$mysqlhost','$username','$password');
     mysql_select_db('$database',$db);
   
?>

This is the function i use for showing what i want:
     function displayTasks() {
      
       $TBS = new clsTinyButStrong;
       $TBS->LoadTemplate('html/tasks_tasks.html');
       $TBS->MergeBlock('blk1',$db,'SELECT * FROM wms_tasks ORDER BY task_id DESC');
       $TBS->Show();
     }

And the template:
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<center>

<table width="660" cellspacing="1" class="table1">
<tr>
<td colspan="3" class="table2" height="20" width="50%">
<p align="left" class="text1">Tasks</p>
</td>
<tr><td class="text4" align="right" colspan="3" height="20" width="100%">
<a href="?action=newtask">Add Task</a></td></tr>
<tr height="20"></tr>
<tr class="text3f">
<td width="460">Name</td>
<td width="100" align="center">User</td>
<td width="100" align="center">Progress</td>
</tr>
<tr class="text4">
<td width="460"><a href="index.php?action=showtask&id=[blk1.task_id]">[blk1.task_title;block=tr]</a></td>
<td width="100" align="center"><a href="users.php?action=getuser&id=[blk1.task_user]">[blk1.task_user;block=tr]</a></td>
<td width="100" align="center">[blk1.task_progress;block=tr]</td>
</tr>
</tr>
<tr bgcolor="#CACACA" class="text4">
<td width="460"><a href="index.php?action=showtask&id=[blk1.task_id]">[blk1.task_title;block=tr]</a></td>
<td width="100" align="center"><a href="users.php?action=getuser&id=[blk1.task_user]">[blk1.task_user;block=tr]</a></td>
<td width="100" align="center">[blk1.task_progress;block=tr]</td>
</tr>
<tr class="text4">
<td colspan="3"><center><br /><br />[blk1;block=tr;nodata]There is no data.</center></td>
</tr>
<tr><td colspan="2" height="30" width="100%"></td></tr>
</table>
</center>

</body>
</html>
By: Radeon
Date: 2004-07-31
Time: 03:01

Re: Merge block error

Also, do i always have to specify the database connection variable when i fetch something from the database, can't i just work with an included database file that always is active?
By: Radeon
Date: 2004-07-31
Time: 03:17

Re: Merge block error

Ok, i'm so sorry for all this ranting, but i tried some stuff out and it seams like it gimped when i used the regular database connection. But when i now didn't include the database connection and instead added it to the function it worked just fine.

I would still love an answer for the post above, since i don't want to define the database connection on every page.
By: Skrol29
Date: 2004-07-31
Time: 12:11

Re: Merge block error

Hi,

In your displayTasks() function, $db is a local variable which doesn't point an the connection.
You have to add:
global $db;
By: Skrol29
Date: 2004-07-31
Time: 12:14

Re: Merge block error

What is usually done is to code the connection into a sub-script file.
Then each script that need the connection calls the sub-script using include() or include_once() functions.

I think MySQL can perform persistant connections but you have to read the PHP documention for this.