Results 1 to 2 of 2

Thread: Get POST info problem

  1. #1

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Resolved Get POST info problem

    I'm creating a poll script with up to 10 available answers. I'm using the below code to check answers and add them into my mySQL database however all the POST "answers" are returning blanks when they shouldn't. Can someone help me out?

    PHP Code:
    //This is my current code
    for($i=1;$i<11;$i++) {

    if (
    $_POST['answer$i'] != "") {
    $answer $_POST['answer$i'];
    $add_answer mysql_query("INSERT into answers VALUES('$id', '$answer, '0')"$db);

    PHP Code:
    //If I use this is picks up the POST "answer" value
    $answer $_POST['answer1'];

    //but this doesn't
    $i="1";
    $answer $_POST['answer$i']; 
    Last edited by lintz; Jan 19th, 2005 at 06:28 AM.

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Get POST info problem

    If you want to embed variables into your stirngs, you need to use double quotes, like this:

    $_POST["answer$i"]

    Single quotes do not allow embedded variables or any escape characters except \' and \\.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

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



Click Here to Expand Forum to Full Width