[Solved] Opened emails trying to update database column

Hi all

I’m trying to update a column in my database using a small snippet of PHP (Zend FW), still very new just wondering if anybody can spot what I’m doing wrong?

I basically have a column ‘opened_email’ in my DB with a default value ‘0’ which is being refrence by an email.
When this code is run, the ‘opened_email’ is supposed to update to ‘1’, whatever email address is in the GET url.

Can anybody spot what I’m doing wrong?

$email = $_GET['email'];

$config = array
(
  'host'     => $WHG_DB_HOST,
  'port'     => $WHG_DB_PORT,
  'username' => $WHG_DB_USER,
  'password' => $WHG_DB_PASSWD,
  'dbname'   => $WHG_DB_REPLDB
);

$db = new Zend_Db_Adapter_Pdo_Mysql($config);

$data = array
(
  'opened_email' => '1'
);
$where[] = "email = $email";
  
$db = new Zend_Db_Adapter_Pdo_Mysql($config);
$n = $db->update('send_a_mate', $data, $where);

$db->closeConnection();

The above is in a file attached to an image in an email, when this email is opened the url of the image calls the file, which should run and update as above. You’ve probably seen this technique used before, when administrates are trying to track how many emails have been opened.

Thanks, Barry

I’m gonna guess it’s right here.

$email wont have quotes around it, so mysql is gonna bork on an unrecognized string.

Thanks StarLion, though this is not the answer unfortunately.
I’ve even tried manually:

https://test.example.com/opened_email.php?email=example@client.com

The 1x1 image loads ok, though I just can’t figure out why the database is not updating ??

I also tried without the ’ ’ with this being a int in the DB, nothing.

'opened_email' => 1

Anyone?

Thanks, Barry

I’ve just spent the last 4 half hours trying to turn a 0 into a 1 :smiley:

Anyhow, I changed things around slightly and after much trail and error the snippet that fixed it:

$result = $db->query("UPDATE `send_a_mate` SET opened_email=1 WHERE email='$email'"); 

Barry

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.