Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2009

    Unanswered: Problem inserting textarea into DB

    I am new to MySQL, PHP, etc...

    I am trying to insert a text description into MySQL. All of my other fields are working, except the textarea description. I would appreciate any insight:

    Html Code:

    <TEXTAREA NAME="description" COLS="35" ROWS="5">

    Php Code:

    $mlsID = $_POST['mlsID'];
    $title = $_POST['title'];
    $propType = $_POST['propType'];
    $propTypeAlt = $_POST['propTypeAlt'];
    $price = $_POST['price'];
    $priceType = $_POST['priceType'];
    $propStatus = $_POST['propStatus'];
    $street = $_POST['street'];
    $street2 = $_POST['street2'];
    $city = $_POST['city'];
    $state = $_POST['state'];
    $zip = $_POST['zip'];
    $county = $_POST['county'];
    $area = $_POST['area'];
    $school = $_POST['school'];
    $bedrooms = $_POST['bedrooms'];
    $bathrooms = $_POST['bathrooms'];
    $stories = $_POST['stories'];
    $propSize = $_POST['propSize'];
    $yearBuilt = $_POST['yearBuilt'];
    $yearRenovated = $_POST['yearRenovated'];
    $description = $_POST['description'];

    mysql_connect ("...") or die ('Error: ' . mysql_error());
    mysql_select_db ("...");

    $query="INSERT INTO listing (propertyID, mlsID, title, propType, propTypeAlt, price, priceType, propStatus, street, street2, city, state, zip, county, area, school, bedrooms, bathrooms, stories, propSize, yearBuilt, yearRenovated, description, postDate)
    VALUES ('', '$mlsID', '$title', '$propType', '$propTypeAlt', '$price', '$priceType', '$propStatus', '$street', '$street2', '$city', '$state', '$zip', '$county', '$area', '$school', '$bedrooms', '$bathrooms', '$stories', '$propSize', '$yearBuilt', '$yearRenovated', '$description', '2009-01-25')";

    mysql_query($query) or die ('Error adding the New Listing');

    echo "New Listing successfully added!";

    Hopefully I provided enough info and someone can help.

  2. #2
    Join Date
    Mar 2007
    Maybe you should try posting all of your code. I don't see a problem with any of the code you posted so far.

  3. #3
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    Im not sure we are at he send the full script stage yet

    PHP Code:
    VALUES ('''$mlsID''$title''$propType''$propTypeAlt''$price''$priceType''$propStatus''$street''$street2''$city''$state''$zip''$county''$area''$school''$bedrooms''$bathrooms''$stories''$propSize''$yearBuilt''$yearRenovated''$description''2009-01-25')"; 
    looks fishy to me

    you only should encapsulate non numeric columns
    I'm suspicious of
    PHP Code:
    VALUES (''[COLOR="Red"],[/COLOR'$mlsID'
    it probably should be
    PHP Code:
    VALUES (''.'$mlsID'
    if $mlsID is numeric
    PHP Code:
    VALUES (''.$mlsID.", 
    have you examined $query to see if what you are sending to the SQL engine is waht you think you are sending?

    my guess is that you have a problem with the commas and numeric columns, and you are fixating on the detail of error message, rather than taking that as MySQL throwing its hands up at that point.

    PHP Code:
    .....VALUES ($mlsID'$title', ......, $bathrooms'$stories''$propSize'$yearBuilt$yearRenovated'$description''2009-01-25')"; 
    having just displayed your code using the PHP tags, another problem seems to be that you are using 2 x ' to form " you can encpasualte stings using either " or ' BUT not 2 x '
    Last edited by healdem; 02-02-09 at 03:42.
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts