Jump to content

Recommended Posts

Hi,

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?

Link to comment
https://forums.phpfreaks.com/topic/2540-php-mailer-update-mysql-database/
Share on other sites

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

 

<?php require_once('../Connections/dbcon.php'); ?>
<?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

<?php
mysql_free_result($Recordset1);
?>

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);

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. 
mysql_connect($myhost,$myusername,$mypass); 
@mysql_select_db($dbname); 
$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']; 

if(!$sql){ 
   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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.