Data not going into database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rfigley
Forum Commoner
Posts: 70
Joined: Sun Apr 21, 2002 7:10 pm

Data not going into database

Post by rfigley »

I have a form, submitting data to the database, and all is going in except for paragraph_1. No errors. The text just not going into the field of the database. All others are going fine.

Here's the HTML form to enter the data:

<input name="newsletter_title" size="100">
<input name="newsletter_title2" size="100">
<textarea name="paragraph_1" cols="75" id="paragraph_1"></textarea>
<textarea name="paragraph_2" cols="75" id="paragraph_2"></textarea>



Here's the command inserting into the table:

Code: Select all

$sql = "INSERT INTO tbl_newsletter_sections (newsletter_title,newsletter_title2,paragraph_1,paragraph_2)
   VALUES ('$newsletter_title','$newsletter_title2','$paragraph_1','$paragraph_2')";
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

what are u using for a action on the form? How/where are u passing the variables?
rfigley
Forum Commoner
Posts: 70
Joined: Sun Apr 21, 2002 7:10 pm

Post by rfigley »

The action is as follows: <form action="edit_newsletter_now.php">

the "edit_newsletter_now.php" file contains the insert command shown,
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

If you echo $sql; before inserting into the db, do you see the paragraph_1 info ok? If so then the problems probably with the form, otherwise it's probably on the db side. I'm presuming the paragraph_1 type and the paragraph_2 type are the same in the db?
evilMind
Forum Contributor
Posts: 145
Joined: Fri Sep 19, 2003 10:09 am
Location: Earth

Post by evilMind »

Check to see that paragraph_1 is being picked up upon form submission.

eg: right after the $sql assignment do a " die($sql); " check to make sure that the query looks proper (' and " are escaped etc.)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

evilMind wrote:Check to see that paragraph_1 is being picked up upon form submission.

eg: right after the $sql assignment do a " die($sql); " check to make sure that the query looks proper (' and " are escaped etc.)
' (single quotes) do not need to be escaped :P
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

<?php
$sql = "INSERT INTO tbl_newsletter_sections SET newsletter_title='$newsletter_title',newsletter_title2='$newsletter_title2',paragraph_1='$paragraph_1',paragraph_2='paragraph_2'";
?>
Try this?
evilMind
Forum Contributor
Posts: 145
Joined: Fri Sep 19, 2003 10:09 am
Location: Earth

Post by evilMind »

Phenom wrote:
evilMind wrote:Check to see that paragraph_1 is being picked up upon form submission.

eg: right after the $sql assignment do a " die($sql); " check to make sure that the query looks proper (' and " are escaped etc.)
' (single quotes) do not need to be escaped :P
single quotes need to be escaped if you're query consists of single quotes. Actually for security reasons ALL QUOTES should be escaped.
Post Reply