Jump to content


This topic is now archived and is closed to further replies.


PHP mailer + update mysql database

Recommended Posts


First time here, long time geek.


I've been mulling over a problem for the last couple of days, and thought it was time to look for a little help in the right direction.


Basically, I have an admin page with a list of registered users details in a dynamic table. In one of the fields, called "status", I have 2 buttons each in their own form that when one is clicked, goes to a mailer1.php and is supposed to send the email in mailer1.php to the user in the row of the dynamic table and update the status field in the mysql database. And when the other is clicked, goes to mailer2.php and does the same.


The forms with the buttons is here http://croc.ftw.net.nz/extras/form.txt and works as far as going to the mailers.php


The mailers.php of which there are 2 different versions (out of the many that I have tried :/ ) are here http://croc.ftw.net.nz/extras/2.txt and here http://croc.ftw.net.nz/extras/3.txt


They both disply no errors when initiated, but then they both do nothing, niether send the email, nor update the database.


Any directional help would be appreciated. Am I going in the right direction? Can you see any huge errors? Is there lots of code missing? Need any more info?

Share this post

Link to post
Share on other sites

Also, Ive tried adding the Dreamweaver recordset to the page which adds


<?php require_once('../Connections/dbcon.php'); ?>
mysql_select_db($database_dbcon, $dbcon);
$query_Recordset1 = "SELECT * FROM users";
$Recordset1 = mysql_query($query_Recordset1, $dbcon) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

to the top of the page, and


to the bottom, but then I get the error "Warning: mysql_free_result(): 7 is not a valid MySQL result resource in /home/croc/public_html/admin/mailerApprove.php on line 64


Line 64 is the mysql_free_result($Recordset1);

Share this post

Link to post
Share on other sites



name="Submit" on your mailing.php


but on mailing1 and 2 u used





Share this post

Link to post
Share on other sites

Yes I noticed that after posting and changed it in the form from capital S to lowercase. Made no difference, so reshuffled it a little and am now here:

// Update info on the Database. 
$sql = mysql_query("UPDATE users SET approved='No' WHERE 'userid' = '$userid'") 
       or die (mysql_error()); 
// Define post fields into simple variables. 
$userid = $_POST['userid']; 
$username = $_POST['username']; 
$name = $_POST['name']; 
$email = $_POST['email']; 
$approved = $_POST['approved']; 

   echo 'error....blah.'; 
} else { 
if(isset($_POST['submit'])) { 
   $userid = $_POST['hiddenField']; 
   // Email the user! 
   $subject = "subject in here"; 
   $message = "Hi $username, blah blah blah 
with the following information: 

Username: $username 
Real Name: $name 
Email: $email 
Clan: $clan 

Body of messege. 
blah blah blah 

This is an automated response, please do not reply!"; 
   mail($email, $subject, $message, 
       "From: Me <me@me.com"); 
   include 'admin.php'; 


which now gives me a "No Database Selected". So, that would explain it not updating the database O_o, but its confused me as to why its not selecting the database.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.