You shouldn't have a semicolon at the end of your class declaration/closing
bracket. Also, I'm not sure if it would cause a problem, but try using standard
file extensions instead of things like .cls. Lastly, just for sake of
readability, you might want to simplify your naming scheme; this was a chore to
read.
Edward Dudlik
Becoming Digital
www.becomingdigital.com
Did I help you? Want to show your thanks?
www.amazon.com/o/registry/EGDXEBBWTYUU
----- Original Message -----
From: "ed anderson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, 02 July, 2003 08:34
Subject: [PHP-DB] converting function to class and function (object)
Dell 4500, mem 1g, disk 45g, mhz 2g, Mysql-3.23.54a-linux-i686, PHP-4.30,
httpd_2.0.44, moxilla 1.0.1
Can someone help converting a function to a class and function.
The included function in example 1 works as expected
but the include class and function in example 2 does not.
What can I do to fix this problem.
Note that example 1 executed "0f" and "1f" echos in addition
to all echos in the main(?) php script, where as example
2 stops after the main(?) php script echo "2" which means the
{include ("./inc/tcb/tmtb_connect_tbc_db.cls");} statement
was parsed but had errors.
included Function for example 1
<?php
# include ("tmtb_connect_tbc_db.inc");
function connect_tbc_db()
{
echo " 0f <br>";
$tmtb_db = mysql_connect("localhost", "root")
or die ("die tmtb_connect_tbc_db.inc mysql_connect $tmtb_db\n");
echo " 1f <br>";
mysql_select_db("tbc_db", $tmtb_db)
or die ("die tmtb_connect_tbc_db.inc mysql_select_db
$tmtb_db\n");
echo "<br> tmtb_connect_tbc_db.inc return $tmtb_db <br>";
return $tmtb_db;
}
?>
included Class and Function for example 2
<?php
# include ("tmtb_connect_tbc_db.cls");
class connect_tbc_db_cls
{
var $tmtb_db = 0;
#
function connect_tbc_db()
{
echo " 0f <br>";
this->$tmtb_db = mysql_connect("localhost", "root")
or die ("die tmtb_connect_tbc_db.cls mysql_connect
this->$tmtb_db\n");
echo " 1f <br>";
# mysql_select_db("tbc_db", this->$tmtb_db)
# or die (" die tmtb_connect_tbc_db.cls mysql_select_db
this->$tmtb_db\n");
echo "<br> tmtb_connect_tbc_db.cls return this->$tmtb_db <br>";
return this->$tmtb_db;
}
};
?>
using Mozilla example 1 ************************************
<html><head><title>tmtb_r_select_html_3.php</title></head>
<body>
tmtb_r_select_html_3.php <BR><BR>
<!-- including class and function<BR><BR> -->
including function<BR><BR>
<?php
## tmtb_connect_tbc_db.inc
echo " 1 <br>";
#
#include ("./inc/tcb/tmtb_connect_tbc_db.cls");
#echo " 2 <br>";
#$a = new connect_tbc_db_cls();
#echo " 3 <br>";
#$tmtb_db = $a->connect_tbc_db();
#echo " 4 <br>";
#
include ("./inc/tcb/tmtb_connect_tbc_db.inc");
echo " 2 <br>";
$tmtb_db = connect_tbc_db();
echo " 3 <br>";
## define_variables
include ("./inc/tmr/dat_tmr_variables.inc");
include ("./inc/html/html_variables.inc");
#
echo " 4 <br>...<br>...<br>...<br>";
?>
<br><br>
#
tmtb_r_select_html_3.php end <BR><BR>
</body>
</html>
submit
http://127.0.0.1/tmtb_r_select_html_3.php
example 111111111111111111111111111111111 output follows
tmtb_r_select_html_3.php
including function
1
2
0f
1f
tmtb_connect_tbc_db.inc return Resource id #3
3
4
...
<snip>
# tmtb_r_select_html_3.php end
end example 11111111111111111111111111111
using Mozilla example 2 **********************************
<html><head><title>tmtb_r_select_html_3.php</title></head>
<body>
tmtb_r_select_html_3.php <BR><BR>
including class and function<BR><BR>
<!-- including function<BR><BR> -->
<?php
## tmtb_connect_tbc_db.inc
echo " 1 <br>";
#
include ("./inc/tcb/tmtb_connect_tbc_db.cls");
echo " 2 <br>";
$a = new connect_tbc_db_cls();
echo " 3 <br>";
$tmtb_db = $a->connect_tbc_db();
echo " 4 <br>";
#
#include ("./inc/tcb/tmtb_connect_tbc_db.inc");
#echo " 2 <br>";
#$tmtb_db = connect_tbc_db();
#echo " 3 <br>";
## define_variables
include ("./inc/tmr/dat_tmr_variables.inc");
include ("./inc/html/html_variables.inc");
#
echo " 4 <br>...<br>...<br>...<br>";
?>
<br><br>
#
tmtb_r_select_html_3.php end <BR><BR>
</body>
</html>
submit
http://127.0.0.1/tmtb_r_select_html_3.php
example 222222222222222222222222222222222 output follows
tmtb_r_select_html_3.php
including class and function
1
2
end example 22222222222222222222222222222
Thanks
ed anderson
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php