Current location: Hot Scripts Forums » Programming Languages » PHP » Auto-emailing on table insert


Auto-emailing on table insert

Reply
  #1 (permalink)  
Old 10-11-03, 04:27 PM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
Post Auto-emailing on table insert

Hopefully this is something simple I'm missing. When an insert query is done, I want an automatic email sent to members email addresses, which are stored in a different table than the insert table.

The table I'm inserting into is called "artist". After the insert query, I want to query a table named "maillist" to get the members email addresses. The "maillist" fields are named id, email_name, email. I keep getting a parse error on line 13. Heres the code i have.

php
include("dbinfo.inc.php");
$my_website=("www.mdhwebdesign.com");
$dbh=mysql_connect ("localhost", "$username", "$password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db("$database");
$query="INSERT INTO artist VALUES ('','$fname','$email','$category','$artist_name',' $song_title','$lyrics','')";
$result=mysql_query($query);
$query2=("SELECT email_name,email FROM maillist");
$result2=$this->db->db_query($query2);
$row=$this->db->db_fetch_array($result2);
$emails=$row['email_name'];
while($row=$this->db->db_fetch_array($result2)) {
$emails=. "," . $row['email_name'];
}
$message = "$fname has just added the song '$song_title' by '$artist_name to our website.";
mail($emails,"A new song has been added.",$message,"From: $my_website\r\n");



echo "<meta http-equiv=\"refresh\" content=\"0; url=maillist.php\" />\n";
/php

Any thoughts?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 10-12-03, 10:39 AM
darkcarnival's Avatar
darkcarnival darkcarnival is offline
PHP/MySQL coder
 
Join Date: Jun 2003
Location: Michigan
Posts: 939
Thanks: 0
Thanked 0 Times in 0 Posts
hmm,

A parse error if you dont know means a character is either missing or is added and not suppose to be there.Now after that echo place a } there and take the } b4 the $email. Doing this will allow the message to send.try that.
__________________
Elite Bulletin Board
http://elite-board.us
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 10-12-03, 12:32 PM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
Yes, I couldn't figure out what was in the wrong place. I tried moving the brackets and still getting parse errors. Can you show me how you'd write the code, because I'm probably misinterpreting the way you explained it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 10-13-03, 05:21 AM
Snake Shift Snake Shift is offline
New Member
 
Join Date: Oct 2003
Location: dunno
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Not sure if this will help...

while($row=$this->db->db_fetch_array($result2)) {
$emails=. "," . $row['email_name'];
}


Try this instead...

$emails.= "," . $row['email_name'];


The string/arithmetic operators go before the assignment operator.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 10-13-03, 10:09 AM
jewellgr jewellgr is offline
Wannabe Coder
 
Join Date: Aug 2003
Location: Michigan USA
Posts: 111
Thanks: 0
Thanked 0 Times in 0 Posts
I noticed the same error that he had, this should fix the problem.
__________________
ArecaWeb Team
Gregg Kenneth Jewell

Last edited by jewellgr; 10-13-03 at 10:14 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 10-13-03, 11:14 AM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
Thnx for the response, but now I'm getting this...

Fatal error: Call to a member function on a non-object in /home/blahblahblah/php/songinsert.php on line 9

Also, I changed the second query to select only from the email field, and changed the leter references to match
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Validator ctrl in table cell : Strange behaviour sunny_doncaster ASP.NET 6 07-31-08 10:43 AM
moving data from table to table ..please help! geneane ASP 2 09-22-03 08:02 PM
Auto ID and DateTime raven001 ASP 0 09-17-03 04:31 PM
insert statement sasi ASP 0 08-11-03 10:38 PM
Just learning: how do I update information in table? paulj000 PHP 3 08-07-03 11:49 AM


All times are GMT -5. The time now is 06:40 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.