I have a function that works perfectly (from within a script). But when I
make it a class (object) and call it from an external file, I get the
following error:
Warning: Missing argument 1 for display_records() in
http://www.friendshipcenter.com/Objects/display_records.inc on line 5
Warning: Missing argument 2 for display_records() in
http://www.friendshipcenter.com/Objects/display_records.inc on line 5
After the warnings, it executes the function without passing values to the
variables (i.e., it doesn't work), and then it executes the function a
second time perfectly (with the appropriate variables).
Line 5 is this:
function display_records($row, $record_count)
It displays the first error message for $row, and the second error message
for $record_count.
I call the function with this:
$my_records = new Display_Records;
$my_records - display_records($row, $record_count);
The full scripts are below.
What I tried that didn't help was declaring the variables in the class with:
class Display_Records {
var $row;
var $record_count;
I also tried setting defaults for the variables (er, attributes) with this
(it didn't help):
$my_records = new Display_Records;
$my_records - row = $row;
$my_records - record_count = 1;
$my_records - display_records($my_records - row, $my_records -
record_count);
This is my first try at OOP. The code is for a personal ad website
(FriendshipCenter.com). Here's the full class script, followed by the
script I use to call the function.
--
Thomas David Kehoe, author of
THE EVOLUTION OF INTIMATE RELATIONSHIPS
How Our Brains Are Hardwired For Relationships
http://www.FriendshipCenter.com/TEIR/
?php
class Display_Records {
function display_records($row, $record_count) {
//Calculate age
$current_date = (date(Y-m-d));
$birthdate = $row[BIRTHDATE];
$age = ($current_date - $birthdate);
// Display record number.
echo Row number:nbsp;, ($record_count + $advance_row), p;
// Display username and e-mail address
echo font color=greenUsername: /font, $row[USER_NAME],
p;
echo font color=greenE-mail address: /fonta href=mailto:;,
$row[EMAIL_ADDRESS], , $row[EMAIL_ADDRESS], /ap;
// Display the information provided by the member. Empty fields
aren't displayed.
if ($row[DISABILITY_1 OR DISABILITY_2 OR DISABILITY_3 OR
DISABILITY_4 OR DISABILITY_5 OR DISABILITY_6 OR DISABILITY_7 OR
DISABILITY_8]) {echo font color=greenDisability, disease, or condition:
/font, $row[DISABILITY_1], , , $row[DISABILITY_2], , ,
$row[DISABILITY_3], , , $row[DISABILITY_4], , , $row[DISABILITY_5], ,
, $row[DISABILITY_6], , , $row[DISABILITY_7], , , $row[DISABILITY_8],
p;}
if ($row[LIFE_STORY]){echo font color=greenLife story:
/font, $row[LIFE_STORY], p;}
if ($row[PHOTO_URL]){echo IMG HEIGHT=250 SRC=,
$row[PHOTO_URL], p;}
if ($row[PHOTO_URL]){echo font color=greenPhoto URL: /fonta
href=, $row[PHOTO_URL], , $row[PHOTO_URL], /ap;}
if ($row[HOMEPAGE_URL]){echo font color=greenPersonal website
URL: /fonta href=, $row[HOMEPAGE_URL], , $row[HOMEPAGE_URL],
/ap;}
if ($row[CITY]){echo font color=greenCity: /font,
$row[CITY], p;}
if ($row[STATE]){echo font color=greenState: /font,
$row[STATE], p;}
if ($row[COUNTRY]){echo font color=greenCountry: /font,
$row[COUNTRY], p;}
if (($row[BIRTHDATE]) != -00-00) {echo font
color=greenAge: /font, $age, p;}
if ($row[GENDER]){echo font color=greenGender: /font,
$row[GENDER], p;}
if ($row[EDUCATION]){echo font color=greenEducation: /font,
$row[EDUCATION], p;}
if ($row[PROFESSION]){echo font color=greenProfession:
/font, $row[PROFESSION], p;}
if ($row[MARITAL_STATUS]){echo font color=greenMarital status:
/font, $row[MARITAL_STATUS], p;}
if ($row[SEXUAL_ORIENTATION]){echo font color=greenSexual
orientation: /font, $row[SEXUAL_ORIENTATION], p;}
if ($row[RELIGION]){echo font color=greenReligion: /font,
$row[RELIGION], p;}
if ($row[RACE]){echo font color=greenRacial or ethnic group:
/font, $row[RACE], p;}
if ($row[HEIGHT]){echo font color=greenHeight: /font,
$row[HEIGHT], inchesp;}
if ($row[WEIGHT]){echo font color=greenWeight: /font,
$row[WEIGHT], poundsp;}
if ($row[SMOKING]){echo font color=greenSmoking: /font,
$row[SMOKING], p;}
if ($row[DRINKING]){echo font color=greenDrinking: /font,
$row[DRINKING], p;}
if ($row[LANGUAGE]){echo font color=greenLanguage: /font,
$row[LANGUAGE], p;}
// Display banner ad.
echo centeriframe
src=http://leader.linkexchange.com/1/X1258133/showiframe? width=468
height=60 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0
scrolling=noa href=http://leader.linkexchange.com/1/X1258133/clickle
target=_topimg width=468 height=60 border=0 ismap
src=http://leader.linkexchange.com/1/X1258133