Page 1 of 1

passing on vars to class function -> function

Posted: Thu Jun 02, 2005 6:08 pm
by ol4pr0
Ok.. this may sound all a bit weird but anyway..

Trying to send a mail, mail arrives fine, no junk mail problem or whatever but
the part insertSearch is not being included in the mail :(

After a select query i am trying to pass on the results array like this.

Send and create the Message:

Code: Select all

#$vacSearch is een array directly from result
#$vacSearch = $dbc->getQuery("AND THE QUERY");
mail($too,$subject,_vacClass::_alert_reg($too,trim($nombre),$vacSearch),$headers);
The actuall message body:

Code: Select all

#$mk variable is for something else. which also works.
function _alert_reg($mk,$nmbre,&$vacSearch) {
$message = '<html><body><LOTS OF HTML CODE WHICH ARRIVES FINE>';
			$message.= _vacClass::_insertSearch(&$vacSearch);
$message .= '</body></html>';
			return $message;
	}
To insert the $message part _insertSearch

Code: Select all

#_replace_esp ALSO WORKS.. NO ERRORS ON THAT PART:
	function _insertSearch(&$vacSearch) {
		foreach( $vacSearch as $row ) {
			$vList = '
			<tr>
				<td style="width:166px;">
				<a href="ht*p://***/">'._vacClass::_replace_esp( $row->fvac ).'<a/></td>
				<td style="width:208px"; align="center">
				<a href="ht*p://***/">'._vacClass::_replace_esp( $row->svac ).'</a></td>
			</tr>
			';
		}
		return $vList;
	}

Posted: Thu Jun 02, 2005 9:25 pm
by John Cartwright
shouldn't $row->fvac just be $row in this section


Code: Select all

foreach( $vacSearch as $row ) {
            $vList = '
            <tr>
                <td style="width:166px;">
                <a href="ht*p://***/">'._vacClass::_replace_esp( $row->fvac ).'<a/></td>
                <td style="width:208px"; align="center">
                <a href="ht*p://***/">'._vacClass::_replace_esp( $row->svac ).'</a></td>
            </tr>
            ';

Posted: Fri Jun 03, 2005 1:26 am
by ol4pr0
Hmm could try that. but i only want to receive that particular row.

Did a small test by passing it from one function to another one..
And it did arive fine ( with $row->fvac). So i am kinda.. in the dark on why it doesnt go like i want it hehe..

Basicly what happends there is that it will create a 2 column row with around 10 things listed in it.

--------- -----------
--------- -----------

ect...

$vacSearch is still an array ( object ) or should be!

Posted: Fri Jun 03, 2005 3:06 am
by Syranide
your problem is the fact that you don't append to the $vList, each loop you start from scratch, thus discarding any rows before that.

Posted: Fri Jun 03, 2005 8:29 am
by ol4pr0
Kinda early here in EC at the moment, what u mean i am appending the vList?

Posted: Fri Jun 03, 2005 9:26 am
by Syranide

Code: Select all

foreach( $vacSearch as $row ) {
            $vList = '
            <tr>
                <td style="width:166px;">
                <a href="ht*p://***/">'._vacClass::_replace_esp( $row->fvac ).'<a/></td>
                <td style="width:208px"; align="center">
                <a href="ht*p://***/">'._vacClass::_replace_esp( $row->svac ).'</a></td>
            </tr>
            ';
... look yourself... what do you do... you loop throu each rom ... and eachtime you set the $vList ... then you return it ... summary? you only return the last one as you do not append.

Posted: Fri Jun 03, 2005 9:52 am
by ol4pr0

Code: Select all

foreach( $vacSearch as $row ) {
            $vList .= ' # this is what u mean i believe ?
            <tr>
                <td style="width:166px;">
                <a href="ht*p://***/">'._vacClass::_replace_esp( $row->fvac ).'<a/></td>
                <td style="width:208px"; align="center">
                <a href="ht*p://***/">'._vacClass::_replace_esp( $row->svac ).'</a></td>
            </tr>
            ';
Changed that.. however i still have the problem that the result is completely empty. meaning that part is not being included in the mail @ all. I am sure 100% that it should have something. ( $rows are not empty )

Posted: Fri Jun 03, 2005 10:12 am
by Syranide
tried echoing instead of mailing perhaps?

Posted: Fri Jun 03, 2005 10:31 am
by ol4pr0
Somehow, i had while editing entered a ' :oops: somewhere in the query string.
totally forgotten that i had altered the query.

So works now..

Altho passing the array from body to the other function does leave it blank.
while when i foreach the rows inside that function that creates the message it echos back fine. so.. ill be busy with that..

Thanks


:roll: