Re: [PHP-DB] stumped-mail and database
--- Stuart Felenstein [EMAIL PROTECTED] wrote: --- Jason Wong [EMAIL PROTECTED] wrote: Also just to be certain that you *are* running those lines of code change the echo $to, to echo Before $to echo After $to or something. Some may remember my problem the other day where I was trying to create a mail() block using fields from the database. Finally figured out my problem. Basically I needed to declare the recordset / resultset as a global and move it further up in the script. Things are working way better except I still have one issue. One field is coming from a TEXT column (mysql) I know there is new line formatting in the text. I can't get it to send in the email as the body remains blank. I can do both a print_r and echo and it is fine (except the new lines dissapear) I wonder if it's becasue it's a text column that I am having this problem. global $rsVendorJobs; global $rsRes; global $rsCL; $to = $rsVendorJobs-Fields('Conmail'); $subject = $rsVendorJobs-Fields('RefEm'); $body = $rsCL-Fields('LurkCovLet'); $headers = From: [EMAIL PROTECTED]; mail($to,$subject,$body,$headers); The field that comes up blank in the email is the $body line. I've tried double quotes in various places. Wonder if I'm missing something ? Thank you Stuart -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] stumped-mail and database
--- Jason Wong [EMAIL PROTECTED] wrote: What happens when you do this: $to = $rsVendorJobs-fields('Conmail'); echo $to; echo $rsVendorJobs-fields('Conmail'); $to = $rsVendorJobs-fields('Conmail'); echo $to; Same thing: Call to a member function on a non-object in.. Stuart -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] stumped-mail and database
On Tuesday 07 December 2004 19:15, Stuart Felenstein wrote: --- Jason Wong [EMAIL PROTECTED] wrote: Please be explicit, do you mean this what you get?: What happens when you do this: $to = $rsVendorJobs-fields('Conmail'); Call to a member function on a non-object echo $to; Nothing, as $to is undefined (or ill-defined) echo $rsVendorJobs-fields('Conmail'); The contents of 'Conmail' $to = $rsVendorJobs-fields('Conmail'); Call to a member function on a non-object echo $to; Nothing, as $to is undefined (or ill-defined) Also just to be certain that you *are* running those lines of code change the echo $to, to echo Before $to echo After $to or something. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* hard, adj.: The quality of your own data; also how it is to believe those of other people. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] stumped-mail and database
--- Jason Wong [EMAIL PROTECTED] wrote: Also just to be certain that you *are* running those lines of code change the echo $to, to echo Before $to echo After $to or something. Well now I feel like a damn jackass. I just discovered something that doesnt fix the issue, yet reveals the probably cause of the issue. I have this mail block tied into the script as an after trigger, meaning if the insert transaction is succesful, then we can proceed with email. The transactions have been succesful, but apparently there is something funky with the trigger. When I removed the trigger function - to = $rsVendorJobs-Fields('Conmail'); sent me an email and returned the correct value. So I'll now be debugging the trigger function to find out what is up. The road is never straight. Stuart -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] stumped-mail and database
I prefer to assign the db values to loca variables to ensure that I am sending out exactly what I need to. Bastien From: Stuart Felenstein [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: [PHP-DB] stumped-mail and database Date: Mon, 6 Dec 2004 10:05:57 -0800 (PST) I'm trying to send mail out based partially on a recordset/binding. The fields are available but I'm not sure if they need to be turned into a variable first or if I can just reference them in the body of the email. Here is what I tried: $to = $rsVendorJobs-Fields('Conmail'); $subject = $rsVendorJobs-Fields('RefEm'); $body = '$cl'; $headers = From: [EMAIL PROTECTED]; mail($to,$subject,$body,$headers); echo Mail sent to $to; } K...so you know this didn't work. I'm googling around but haven't come up with anything on this subject. Appreciate some pointers please. Stuart -- 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
RE: [PHP-DB] stumped-mail and database
-Original Message- From: Stuart Felenstein [mailto:[EMAIL PROTECTED] Here is what I tried: $to = $rsVendorJobs-Fields('Conmail'); $subject = $rsVendorJobs-Fields('RefEm'); $body = '$cl'; $headers = From: [EMAIL PROTECTED]; mail($to,$subject,$body,$headers); echo Mail sent to $to; } 1) change $to = $rsVendorJobs-Fields('Conmail'); To $to = {$rsVendorJobs-Fields('Conmail')}; Or just $to = $rsVendorJobs-Fields('Conmail'); 2) change $body = '$cl'; To $body = $cl; 3) from mail() docs [this is just for reference, since you're only sending one header it's probably not a problem] Note: You must use \r\n to separate headers, although some Unix mail transfer agents may work with just a single newline (\n). Then we'll see where you are from there... Cheers, - Martin Norland, Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] stumped-mail and database
er, I don't know if it would interest you but here is a class I have been using for ages now (not that I have trouble using mail() for simple jobs) because its simple, packed with functionality and works well: http://phpmailer.sourceforge.net/ the following page hopefully demonstrates how simple it is to setup/use: http://phpmailer.sourceforge.net/extending.html Norland, Martin wrote: -Original Message- ... 1) change $to = $rsVendorJobs-Fields('Conmail'); I suspect that $to would contain something like: (Object) -Fields('Conmail') or something even more garbage like (i.e. ), 'complex' $variables in doubled quotes strings should always be wrapped in curly braces, if only for clarities sake (if you want to know exactly when they are required then RTFM ;-). To $to = {$rsVendorJobs-Fields('Conmail')}; Or just $to = $rsVendorJobs-Fields('Conmail'); this is the best way - saves some string interpolation. 2) change $body = '$cl'; To $body = $cl; 3) from mail() docs [this is just for reference, since you're only sending one header it's probably not a problem] Note: You must use \r\n to separate headers, although some Unix mail transfer agents may work with just a single newline (\n). Then we'll see where you are from there... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] stumped-mail and database
--- Bastien Koert [EMAIL PROTECTED] wrote: I prefer to assign the db values to loca variables to ensure that I am sending out exactly what I need to. Well the binding is one where clause that pulls the correct record for the transaction. Following what you are saying, how does that actually look ? Maybe something like this $myvar = select field from table where id = 2 ? Something as simple as that perhaps ? Stuart -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] stumped-mail and database
--- Norland, Martin [EMAIL PROTECTED] wrote: 1) change $to = $rsVendorJobs-Fields('Conmail'); To $to = {$rsVendorJobs-Fields('Conmail')}; Or just $to = $rsVendorJobs-Fields('Conmail'); 2) change $body = '$cl'; To $body = $cl; Well I'm sure this is not the syntax, but since I've written it both ways I get a : Fatal error: Call to a member function on a non-object in /home/xxx/public_html/appjobb.php on line 39 Which I'm guessing means it is written correctly but now the variable doesn't exist ? Stuart -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] stumped-mail and database
What is $rsVendorJobs, where is it populated? I assumed, from the way you were using it - that it was a class object with a 'fields' function that returns the value of a column when passed the column name. Which, looking back, seems pretty excessively abstracted :) Is $rsVendorJobs just the result of a mysql_query()? If so, you probably just want to be using: $to = $rsVendorJobs['Conmail']; Also note - the case sensitivity may or may not be a problem (you may need to use 'conmail') Otherwise, let's see some code to flesh this out! Cheers, - Martin Norland, Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -Original Message- From: Stuart Felenstein [mailto:[EMAIL PROTECTED] Sent: Monday, December 06, 2004 1:37 PM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] stumped-mail and database --- Norland, Martin [EMAIL PROTECTED] wrote: 1) change $to = $rsVendorJobs-Fields('Conmail'); To $to = {$rsVendorJobs-Fields('Conmail')}; Or just $to = $rsVendorJobs-Fields('Conmail'); 2) change $body = '$cl'; To $body = $cl; Well I'm sure this is not the syntax, but since I've written it both ways I get a : Fatal error: Call to a member function on a non-object in /home/xxx/public_html/appjobb.php on line 39 Which I'm guessing means it is written correctly but now the variable doesn't exist ? Stuart -- 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
RE: [PHP-DB] stumped-mail and database
--- Norland, Martin [EMAIL PROTECTED] wrote: What is $rsVendorJobs It's a recordset which for lack of a better definition is a sql query. Is $rsVendorJobs just the result of a mysql_query()? If so, you probably just want to be using: $to = $rsVendorJobs['Conmail']; Nope, though it didn't throw an error, it was blank. Here is the code. There is actually a transaction that takes place (insert into database) the email is set up as an after trigger to the insert. I'm leaving the transaction out. $query_rsVendorJobs = sprintf(SELECT `VendorJobs`.`Contact`, `VendorJobs`.`Conmail`, CONCAT_WS('-', `VendorJobs`.`JobID`, `VendorJobDetails`.`OptRefCode`, `VendorJobs`.`JobTitle`) AS `RefEm`, `VendorSignUp`.`CompanyName`, `VendorJobs`.`JobID`, `VendorJobs`.`JobTitle`, `VendorJobDetails`.`OptRefCode` FROM `VendorJobs` INNER JOIN `VendorJobDetails` ON (`VendorJobs`.`JobID` = `VendorJobDetails`.`JobID`) INNER JOIN `VendorSignUp` ON (`VendorJobs`.`VendorID` = `VendorSignUp`.`VendorID`) WHERE (VendorJobs.JobID = %s) , $colname__rsVendorJobs); $rsVendorJobs = $-SelectLimit($query_rsVendorJobs) or die($-ErrorMsg()); $totalRows_rsVendorJobs = $rsVendorJobs-RecordCount(); // end Recordset %s = the JobID I've selected on the previous page and passed over with $_POST Hope this is enough. Not sure what else to send. Stuart -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] stumped-mail and database
All I can recommend from here is heavy use of printr() or var_dump() on your variables. $totalRows_rsVendorJobs = $rsVendorJobs-RecordCount(); // end Recordset This clearly means $rsVendorJobs is an object of some sort, probably some custom recordset object as you've said - so your best bet is to var_dump it and look through the information you're presented with, to try and track down what's going wrong or where your data is. Obviously, also, you'll want to print out the query you're using to make sure it's actually correct sql/being populated/etc. Perhaps even run a var_dump($-SelectLimit($query_rsVendorJobs)) to see just what result you're getting back, although from your code it should exactly match a dump of $rsVendorJobs. Good luck, happy hunting - Martin Norland, Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] stumped-mail and database
--- Norland, Martin [EMAIL PROTECTED] wrote: All I can recommend from here is heavy use of printr() or var_dump() on your variables. They are NULL. That is the problem. I can't for the life of me , figure out a way to initialize these variables. Obviously, also, you'll want to print out the query you're using to make sure it's actually correct sql/being populated/etc. Perhaps even run a var_dump($-SelectLimit($query_rsVendorJobs)) to see just what result you're getting back, although from your code it should exactly match a dump of $rsVendorJobs. Yeah , the sql is cool Everything returns as expected. Stuart -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] stumped-mail and database
-Original Message- From: Stuart Felenstein [mailto:[EMAIL PROTECTED] They are NULL. That is the problem. I can't for the life of me , figure out a way to initialize these variables. (Bear with me on this, because I've got nothing remaining to go on...) What do you get from: var_dump($query_rsVendorJobs); var_dump($totalRows_rsVendorJobs); var_dump($-SelectLimit($query_rsVendorJobs)); var_dump($rsVendorJobs); // should match above. // If this one is huge - we may want to hold off on this one var_dump($); Place all of those at the bottom of the script, and I suggest enclosing them within pre tags, for legibility. (print_r is a slightly more legible option, but var_dump gives us more information). - Martin Norland, Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] stumped-mail and database
Stuart Felenstein wrote: --- Norland, Martin [EMAIL PROTECTED] wrote: All I can recommend from here is heavy use of printr() or var_dump() on your variables. They are NULL. That is the problem. I can't for the life of me , figure out a way to initialize these variables. be more specific - its not at all clear which variables are null? is your 'recordset' ($rsVendorJobs) actually an object? if not you have to go into the $-SelectLimit($query_rsVendorJobs) call to find out what is going wrong. Is this the first time you are attempting to use the DB abstraction objects/classes that your code snippets hint at? if so, specify exactly what it is, it may help. also have you checked your error logs? Obviously, also, you'll want to print out the query you're using to make sure it's actually correct sql/being populated/etc. Perhaps even run a var_dump($-SelectLimit($query_rsVendorJobs)) to see just what result you're getting back, although from your code it should exactly match a dump of $rsVendorJobs. Yeah , the sql is cool Everything returns as expected. Stuart -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] stumped-mail and database
--- Norland, Martin [EMAIL PROTECTED] wrote: (Bear with me on this, because I've got nothing remaining to go on...) What do you get from: var_dump($query_rsVendorJobs); var_dump($totalRows_rsVendorJobs); var_dump($-SelectLimit($query_rsVendorJobs)); var_dump($rsVendorJobs); // should match above. // If this one is huge - we may want to hold off on this one var_dump($); I held off on the vary_dump($); The most revealing were: var_dump($query_rsVendorJobs); This is just basically the sql statement: string(513) SELECT `VendorJobs`.`Contact`, `VendorJobs`.`Conmail`, CONCAT_WS('-', `VendorJobs`.`JobID`, `VendorJobDetails`.`OptRefCode`, `VendorJobs`.`JobTitle`) AS `RefEm`, `VendorSignUp`.`CompanyName`, `VendorJobs`.`JobID`, `VendorJobs`.`JobTitle`, `VendorJobDetails`.`OptRefCode` FROM `VendorJobs` INNER JOIN `VendorJobDetails` ON (`VendorJobs`.`JobID` = `VendorJobDetails`.`JobID`) INNER JOIN `VendorSignUp` ON (`VendorJobs`.`VendorID` = `VendorSignUp`.`VendorID`) WHERE (VendorJobs.JobID = 10042) Yet the JobID is correct so that's a positive The other var_dump is: var_dump($rsVendorJobs); this returned alot. I snipped most of it but if you look , well if I look, all the fields have the correct values: object(kt_adorecordset_mysql)(33) { [dataProvider]= string(6) native [fields]= array(14) { [0]= string(12) Hamas Zwicki [Contact]= string(12) Hamas Zwicki [1]= string(18) [EMAIL PROTECTED] [Conmail]= string(18) [EMAIL PROTECTED] [2]= string(24) 10042-A99839-Entry Clerk [RefEm]= string(24) 10042-A99839-Entry Clerk [3]= string(13) Talman Zwicki [CompanyName]= string(13) Talman Zwicki [4]= string(5) 10042 [JobID]= string(5) 10042 [5]= string(11) Entry Clerk [JobTitle]= string(11) Entry Clerk [6]= string(6) A99839 [OptRefCode]= string(6) A99839 } [blobSize]= int(100) [canSeek]= bool(true) [sql]= string(540) SELECT `VendorJobs`.`Contact`, `VendorJobs`.`Conmail`, CONCAT_WS('-', `VendorJobs`.`JobID`, `VendorJobDetails`.`OptRefCode`, `VendorJobs`.`JobTitle`) AS `RefEm`, `VendorSignUp`.`CompanyName`, `VendorJobs`.`JobID`, `VendorJobs`.`JobTitle`, `VendorJobDetails`.`OptRefCode` FROM `VendorJobs` INNER JOIN `VendorJobDetails` ON ...[snip] Stuart -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] stumped-mail and database
var_dump($rsVendorJobs); object(kt_adorecordset_mysql)(33) { [dataProvider]= Looks like you're using the ADODB library ( http://www.certicamara.com/consulta/lib/adodb/docs-adodb.htm ) or similar. ( That may not be the official site, I just bounced around a bit. ) All your previous code looks to have been correct, so I'm not really sure where to go from here. You may want to look into $ADODB_FETCH_MODE and see if you can't just get an associative array with your fields directly out, instead of pulling each little piece out through the convenience function Fields() (which... doesn't seem to be working). Not best practice - in fact, extremely BAD practice, but you should be able to access it with $rsVendorJobs-fields['fieldname']. Note, of course, that that's internal structure of their object - and you should NOT be directly accessing such things. Still, it will help you check if you're sane. I really REALLY don't recommend directly digging into a black box like this unless you know it will never change, or have some good documentation area where people will know to look before upgrading. - Martin Norland, Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] stumped-mail and database
I just thought, if your query object ($) is returning a resultset object then maybe you have to 'loop' the resultset object in order to retrieve the 'row' object(s) from which you can retrieve the data. your resultset object doesn't have a GetRowAssoc() method? [ defined as GetRowAssoc($upper=true) ] Norland, Martin wrote: var_dump($rsVendorJobs); object(kt_adorecordset_mysql)(33) { [dataProvider]= Looks like you're using the ADODB library ( http://www.certicamara.com/consulta/lib/adodb/docs-adodb.htm ) or similar. ( That may not be the official site, I just bounced around a bit. ) All your previous code looks to have been correct, so I'm not really sure where to go from here. You may want to look into $ADODB_FETCH_MODE and see if you can't just get an associative array with your fields directly out, instead of pulling each little piece out through the convenience function Fields() (which... doesn't seem to be working). Not best practice - in fact, extremely BAD practice, but you should be able to access it with $rsVendorJobs-fields['fieldname']. Note, of course, that that's internal structure of their object - and you should NOT be directly accessing such things. Still, it will help you check if you're sane. I really REALLY don't recommend directly digging into a black box like this unless you know it will never change, or have some good documentation area where people will know to look before upgrading. - Martin Norland, Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php