SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Barwick ON Canada
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP variable mysql select statement problem

    can anyone tell me why this code don't work. I run it and I get no results even when I know the variable matches a entry in the database.

    <? include("datacon.inc");
    if(isset($_POST['group_name'])){
    $name = $_POST[group_name];
    }
    $result = mysql_query("SELECT group_id FROM newsletter_group WHERE name='$name'");
    $row = mysql_fetch_array($result);
    $gid = $row["group_id"];
    echo $gid;
    ?>

  2. #2
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    just out of interest, try it like this:

    PHP Code:
     
    $name 
    $_POST['group_name']; 
    You were missing the single quotes!

    Mark

  3. #3
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Barwick ON Canada
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have done that but it still don't work

  4. #4
    SitePoint Wizard Mike Borozdin's Avatar
    Join Date
    Oct 2002
    Location
    Edinburgh, UK
    Posts
    1,743
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try to output the value of $name to check what you get.

  5. #5
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Barwick ON Canada
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok I figured it out the problem wasn't the script it was the way the form sent the data.

    Thanks for your help anyway


Bookmarks

Posting Permissions

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