This topic is locked

Send an e-mail when data is the same.

10/8/2009 8:13:46 AM
PHPRunner General questions
M
mmponline author

I have two tables with similar fields.
Eg.

Table1

Town

Province

Type
Table2

Town

Province

Type
When a new record is added on Table1, I would like to have an e-mail sent to the users that added info in Table2 that is exactly the same. A sort of notification that info is the same.

These mails must be sent to all the users in the Table2 that has comparing info.
Further, I would like to have users to have an option to agree on receiving notification e-mails or not. If selected, mails will be sent, if not selected, mails will not be sent.
Thank you for any helpful tips. I appreciate.

M
mmponline author 10/8/2009

As part of my trying, I've selected the "if record exists" option but get an syntax error:

__

Error type 256

Error description You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'From='SomeValue'' at line 1

URL cargomax.co.za/cargodb/tripsavailableadd.php?

Error file /usr/www/users/cargom/cargodb/include/dbconnection.php

Error line 34

SQL query select * from tripsavailable where From='Pretoria'

Solution This is a general error. It occurs when there is an error in event code or in SQL.

____

The code I'm using is:



//********** Check if specific record exists ************

global $conn;

$strSQLExists = "select * from tripsavailable where From='Pretoria'";

$rsExists = db_query($strSQLExists,$conn);

$data=db_fetch_array($rsExists);

if($data)

{
// if record exists do something
// ********** Send simple email ************

$email="test@test.com";

$from="admin@test.com";

$msg="Hello there\nBest regards";

$subject="Sample subject";

$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];

}

else

{

// if dont exist do something else

}



Obviously the text Pretoria will have to be replaced with a value that corresponds with the current table.

J
Jane 10/8/2009

Stephan,
I recommend you to publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.