Jump to content

PLEASE HELP - INSERT error


forumnz

Recommended Posts

Please please help - getting so frustrated.

 

My script is meant to Email someone (that works), and also is meant to insert data into a db.

 

It won't do the database thing.

 

Please look at my code and help me - thanks so much!

 

<?php
$name = $_POST['name'];
$business_name = $_POST['business_name'];
$emailm = $_POST['email'];
$contact = $_POST['contact'];
$id = $_POST['id'];


include('connectdb.php');

  $cemail = "[email protected]";
  $headers  = "From: $cemail\r\n";
    $headers .= "Content-type: text/html\r\n"; 

include('email.php');

$to = $email;
## Below is for new email
$message = "Hello, <br /><br />You have been sent an email regarding " . $business_name . ". <br /><br />Please note, this message has not been screened by FoodFinder staff and FoodFinder is not responsible for it's content.<br /><br />Regards,<br />FoodFinder Staff<br /><br />Submitted Content:<br /><br />Name: " . $name . "<br />Contact: " . $contact . "<br />Message: " . $emailm . "";
$subject = "FoodFinder Contact";


mail($to,$subject,$message,$headers);
echo $id . "<br>" . $name . "<br>" . $contact . "<br>" . $emailm . "<br>" . $message;


//////////////////


$sql="INSERT INTO submitted_emails (buzzid, name, contact, message, email)
VALUES
('$id','$name','$contact','$emailm','$message')";



?>

 

Thanks,

Sam.

Link to comment
https://forums.phpfreaks.com/topic/88092-please-help-insert-error/
Share on other sites

Did you actually do what I suggested in the other post?  Because you were getting errors because of apostrophes then, and I don't see any changes in your code:

 

Either addslashes() or mysql_real_escape_string() the strings you're inputting.  The reason it'll be generating errors is because you have an apostrophe in one of your inputs somewhere.

 

Do this at your string input stage:

 

 

<?php

$name = mysql_real_escape_string($_POST['name']);

// OR

$name = addslashes($_POST['name']);

?>

Archived

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

×
×
  • 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.