Forums

PHP

This topic is locked

Multiple recordsets with phakt?

Posted 09 Sep 2001 14:45:28
1
has voted
09 Sep 2001 14:45:28 Jochem Peppelenbos posted:
Hi there,

When I try to create multiple recordsets, I get the following error message:

Fatal error: Call to undefined function: execute() in c:\mijn documenten\homepages\www.lapwing.l\support\faq\nl\faq.php on line 14

This is the code created by phakt in UltraDev:

<?php
$Lapwing=$Lapwing->Execute("SELECT * FROM faq, links, productsoort WHERE (PId = Productsoort AND LId = InfoLink1)" or DIE($Lapwing->ErrorMsg());
$Lapwing_numRows=0;
$Lapwing__totalRows=$Lapwing->RecordCount();
?>
<?php
$Systeem=$Lapwing->Execute("SELECT * FROM systeeminuitschakelen" or DIE($Lapwing-
^^^^^ the line above is line 14 ^^^^^^
>ErrorMsg());
$Systeem_numRows=0;
$Systeem__totalRows=$Systeem->RecordCount();
?>

The thing is, if I leave out this second recordset, everything works fine and if I test this specific recordset and the connection to the database in UD, there is no problem either. I suppose it is possible to have multiple recordsets in one PHP document? I hope so???

Does anyone know what's wrong?

Gompy.

Replies

Replied 09 Sep 2001 14:52:47
09 Sep 2001 14:52:47 Jochem Peppelenbos replied:
Ooops,

sorry... when I just re-read my own question I suddenly saw the solution myself...

So.... here's a lesson to everyone and especially myself: never ever name your Connection and your Recordset identically or you variables will be messed up... I know, it's obvious... so it's a very stupid mistake... <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>

Gompy.

Replied 09 Sep 2001 20:15:31
09 Sep 2001 20:15:31 Tim Green replied:
You make a good point there Gompy. Unfortunately, even the best of us get caught out with this sort of thing from time to time.

However, there is a way to make sure that this problem never ever happens to you again.

It is considered good coding practice, and good coding style to name all of your connections with the prefix "conn", and all of your recordsets with the prefix "rs".

This helps when reading your code, as then you know immediately that all variables starting with "conn" refer to a connection, and likewise with "rs".

The first block of your code, above, would therefore look like this :-

&lt;?php
$rsLapwing=$connLapwing-&gt;Execute("SELECT * FROM faq, links, productsoort WHERE (PId = Productsoort AND LId = InfoLink1)" or DIE($connLapwing-&gt;ErrorMsg());
$rsLapwing_numRows=0;
$rsLapwing__totalRows=$rsLapwing-&gt;RecordCount();
?&gt;

Now, doesn't that start to make more sense already ?

Hope this helps <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>

Reply to this topic