passing on vars to class function -> function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

passing on vars to class function -> function

Post 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;
	}
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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>
            ';
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post 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!
Syranide
Forum Contributor
Posts: 281
Joined: Fri May 20, 2005 3:16 pm
Location: Sweden

Post 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.
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Kinda early here in EC at the moment, what u mean i am appending the vList?
Syranide
Forum Contributor
Posts: 281
Joined: Fri May 20, 2005 3:16 pm
Location: Sweden

Post 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.
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post 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 )
Syranide
Forum Contributor
Posts: 281
Joined: Fri May 20, 2005 3:16 pm
Location: Sweden

Post by Syranide »

tried echoing instead of mailing perhaps?
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post 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:
Post Reply