forumnz Posted January 27, 2008 Share Posted January 27, 2008 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 = "no-reply@email.com"; $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. Quote Link to comment https://forums.phpfreaks.com/topic/88092-please-help-insert-error/ Share on other sites More sharing options...
PHP Monkeh Posted January 27, 2008 Share Posted January 27, 2008 Don't make 2 threads about the same subject please Check your other thread for my reply. Quote Link to comment https://forums.phpfreaks.com/topic/88092-please-help-insert-error/#findComment-450666 Share on other sites More sharing options...
forumnz Posted January 27, 2008 Author Share Posted January 27, 2008 Thanks, but I fixed that error. This error is the DB insert. Pleas help, Sam. Quote Link to comment https://forums.phpfreaks.com/topic/88092-please-help-insert-error/#findComment-450679 Share on other sites More sharing options...
revraz Posted January 27, 2008 Share Posted January 27, 2008 Because you don't do anything with the $sql after you define it. You need a mysql_query($sql) in there. Quote Link to comment https://forums.phpfreaks.com/topic/88092-please-help-insert-error/#findComment-450680 Share on other sites More sharing options...
forumnz Posted January 27, 2008 Author Share Posted January 27, 2008 Still not working? Quote Link to comment https://forums.phpfreaks.com/topic/88092-please-help-insert-error/#findComment-450689 Share on other sites More sharing options...
PHP Monkeh Posted January 27, 2008 Share Posted January 27, 2008 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']); ?> Quote Link to comment https://forums.phpfreaks.com/topic/88092-please-help-insert-error/#findComment-450694 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.