Categories > TinyButStrong general >

TBS and ezSQL and MySQL

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Pirjo Posio
Date: 2003-07-13
Time: 14:41

TBS and ezSQL and MySQL

Hello,
I hope you have energy for this too, because I can't fix it myself.
I'm not sure if the error lies in TBS or in ezSQL or the ezSQL-custom functions you gave in TBS support page.

I have modified your MySQL examples to use ezSQL.
All goes well until I get the error message:
Notice: Undefined offset: 7 in C:\Inetpub\wwwroot\includes\ez_sql.php on line 287

I have totally 7 records, which are printed correctly (the same data and output you have in your MySQL examples). The last line of output is: There are 7 displayed lines.

I suppose TBS/ezSQL reads the records 0-6 and tries to read one more time, and produces the error notice.
Here's my code:
PHP:
<?php
include_once "ez_sql.php";
$db = new db("user","password","tbs","localhost");
include_once("tbs_class.php");
$TBS = new clsTinyButStrong;
$TBS->LoadTemplate("tbs_us_examples_ezsql.htm");
$query = "SELECT res_id, res_name, res_score, res_date FROM t_tbs_exemples ORDER BY res_name";
$TBS->MergeBlock("blk1",$db,$query);
$TBS->Show() ;
?>
And HTML (exactly the same as your templatefot MySQL):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>TinyButStrong</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="tbs_us_examples_0styles.css" rel="stylesheet" type="text/css">
</head>

<body>
<p align="center" class="title-page">Example of MySQL Data Merge</p>
<table border="1" align="center" cellpadding="2" cellspacing="0">
  <tr bgcolor="#CACACA">
    <td width="50"><strong>Position</strong></td>
    <td width="150"><strong>Nickname</strong></td>
    <td width="50" align="right"><strong>Score</strong></td>
    <td width="100" align="center"><strong>Date</strong></td>
  </tr>
  <tr bgcolor="#F0F0F0">
    <td align="right">[blk1.#]</td>
    <td>[blk1.res_name;block=row]</td>
    <td align="right">[blk1.res_score]</td>
    <td align="center">[blk1.res_date;frm='dd-mm-yyyy']</td>
  </tr>
  <tr bgcolor="#E6E6E6">
    <td align="right">[blk1.#]</td>
    <td>[blk1.res_name;block=row]</td>
    <td align="right">[blk1.res_score]</td>
    <td align="center">[blk1.res_date;frm='dd-mm-yyyy']</td>
  </tr>
</table>
<p align="center">There are [blk1.#] displayed lines.</p>
</body>
</html>

There should be some test stop reading, but where? Thanks in advance!
-Pirjo
By: Skrol29
Date: 2003-07-15
Time: 14:43

Re: TBS and ezSQL and MySQL

Hi Pirjo,

I've tested your code and it runs ok with me.
-> EzSQL 1.21
-> Php 4.2.0
-> MySQL 3.23.49

I agree with your assumption about records 0 to 6.
Do you use MySQL ?
By: Pirjo Posio
Date: 2003-07-15
Time: 17:16

Re: TBS and ezSQL and MySQL

Hi Skrol,
Yes, I use MySQL.
Probably you don't have E_ALL errors on in php.ini, if you don't get the error notice. I have to use E_ALL because of my ISP, and I want to also.
- Pirjo
By: Skrol29
Date: 2003-07-16
Time: 10:02

Re: TBS and ezSQL and MySQL

How yes you're right.
Now I have 2 notices :

Notice: Undefined property: last_query in e:\mes documents\développement\html\site dev\tbs\test_ezsql\ez_sql.php on line 90

Notice: Undefined offset: 7 in e:\mes documents\développement\html\site dev\tbs\test_ezsql\ez_sql.php on line 287

I'm having a deeper look to understand...
By: Skrol29
Date: 2003-07-16
Time: 13:52

Re: TBS and ezSQL and MySQL

Hi Pirjo,

I can't say if it's a EzSQL problem or not because I don't know the specifications for the GetRow method. The PHP notice we have occurs when a none existing row is asked to the method. Which should not be a mistake because that's the usual way to know if it's the last row or not.

Anyway, I've changed the TBS custom functions in order to make them work .
I gonna ask to the EzSQL creator if the notice message is a bug.

New TBS custom functions for EzSQL :
function tbsdb_db_open(&$db,&$query) {
  $db->get_results($query) ;
  return $db ;
}
function tbsdb_db_fetch(&$db,$num) {
  if ($num<=$db->num_rows) {
    return $db->get_row(null,ARRAY_A,$num-1) ;
  } else {
    return False ;
  }
}
function tbsdb_db_close(&$db) {
  // not needed
}
By: Pirjo Posio
Date: 2003-07-16
Time: 15:19

Re: TBS and ezSQL and MySQL

Now it's working. I couldn't have done the correction by myself, and shouldn't also, because the common EzSQL function was changed.
Thank you very much!
- Pirjo
By: sam
Date: 2006-11-06
Time: 06:38

Re: TBS and ezSQL and MySQL

hey ,
noticed this also happens if you are using CACHE as defined by EZSQL