Jump to content


Photo

Insert record into MYSQL table via a mailscript


  • Please log in to reply
7 replies to this topic

#1 eskimowned

eskimowned
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 25 September 2006 - 11:48 AM

If there is anyone who can tell me where I'm going wrong here that would be awesome.

<?php require_once('../../Connections/Conn1.php'); ?>
<?php
mysql_select_db($database_Conn1, $Conn1);
$query_UpdateCustInfo = "SELECT * FROM Customer";
$UpdateCustInfo = mysql_query($query_UpdateCustInfo, $Conn1) or die(mysql_error());
$row_UpdateCustInfo = mysql_fetch_assoc($UpdateCustInfo);
$totalRows_UpdateCustInfo = mysql_num_rows($UpdateCustInfo);

$company = $_POST['Company'];
$first = $_POST['FirstName'];
$last = $_POST['LastName'];
$event = $_POST['Event'];
$price = $_POST['Price'];

mysql_query("INSERT INTO CUSTOMER (Company, First Name, Last Name, Event, price) VALUES ('$Company', '$first', '$last', '$event', '$price')");
mysql_close(); 

// Grab our config settings 
require_once($_SERVER['DOCUMENT_ROOT'].'/PHPdocs/phpmailer/config.php'); 

// Grab the FreakMailer class 
require_once($_SERVER['DOCUMENT_ROOT'].'/PHPdocs/phpmailer/MailClass.inc'); 

// instantiate the class 
$mailer = new FreakMailer(); 

// Set the subject 
$mailer->Subject = 'This is a test'; 

$mailer->isHTML(true); 

// Send the E-Mail 
// Body 
$mailer->Body = '<img src="http://www.womeninbusiness.co.uk/images/WIBsphere.jpg" alt="WIB logo" /><br /> 

<h2>WIB HTML test</h2> 
<p>Visit us <a href="http://www.womeninbusiness.co.uk" title="Women In Business">Women In Business.co.uk</a> for a loving community!</p> 
<?php echo"Dear $first"?>

<p>Sincerely,<br> 
Shauns Web test </p>';

// Add an address to send to. 
$mailer->AddAddress('shaun@designatedassociates.com', 'shaun');

if(!$mailer->Send()) 
{ 
  echo 'There was a problem sending this mail!'; 
} 
else 
{ 
  echo 'Mail sent!';
} 
$mailer->ClearAddresses(); 
$mailer->ClearAttachments(); 
?> 
<?php
mysql_free_result($UpdateCustInfo);
?>

Any help anyone can offer, is as always greatly appreciated.

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 25 September 2006 - 01:36 PM

What is not working?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 eskimowned

eskimowned
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 25 September 2006 - 02:15 PM

Two things actually:

The MYSQL problem is the update statement at the top, its not updating the table, doesn't produce an error either.

The other poblem I'm having with it, is displaying the form variables with the HTML body of the PHPmailer.

Any help is always greatly appreciated.

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 25 September 2006 - 06:23 PM

Well, i don't see an update statement... you mean the insert statement?  And I'm not sure what you mean by the other problem.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#5 eskimowned

eskimowned
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 26 September 2006 - 07:32 AM

Sorry - I'm an idiot - yes its the INSERT that is not working. My apologies I really need some sleep.

If anyone could help that would be magic.

Also changed the title. My Bad!

#6 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 26 September 2006 - 06:00 PM

Use mysql_error() and see what the problem is.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#7 eskimowned

eskimowned
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 27 September 2006 - 11:23 AM

The error I'm getting is:

Parse error: syntax error, unexpected T_VARIABLE in /hsphere/local/home/designat/womeninbusiness.co.uk/PHPdocs/phpmailer/invoicemail.php on line 15



#8 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 27 September 2006 - 06:43 PM

Well, that's a PHP error... on the $mailer->Body line, I think... not sure if PHP likes multi-lined strings, but I doubt you can imbed another PHP block inside.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users