Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    update does not work

    I have not really been started with php
    and do not know how, but the update does not work.
    The update is in another table.

    Code:
      <?php
     
        $sql = "SELECT Name, Address, group, date FROM members WHERE Name = '$HTTP_POST_VARS[zoekterm]'AND ID_GROUP ='11'";
        $res = mysql_query($sql);
        
        if (mysql_num_rows($res) >= 1)
        {
            while ($row = mysql_fetch_array($res))
            {
                echo "<p>Name: <b>$row[Name]</b><br>";
                echo "Address: <b>$row[Address]</b><br>";
                echo "Group: <b>$row[group]</b><br>";
                echo "Date: <b>$row[date]</b></p>";
       $sql = "UPDATE donatie SET VID = ". $row[Name]."  WHERE nr ='1'";
    
            }
            
        }   
        
    ?>

    I think it's just how I ". $ Row [Name]. " to write, and why should it be so.
    I would like to know this.
    thanks

  • #2
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hi, Maybe this will work ? i don't know is extra space between dot (.) and variable is the problem, but add single quote on VID value maybe help.
    Code:
     
    
       $sql = "UPDATE donatie SET VID = '".$row[Name]."'  WHERE nr ='1'";

  • #3
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,300
    Thanks
    23
    Thanked 612 Times in 611 Posts
    $HTTP_POST_VARS is depreciated Use $_POST['what ever this should be']
    Normally you don't use quotes around a number so '11' and '1' S/B 11 and 1.
    Use $row['Name'] not $row[Name] Same goes for $row[Address] and $row[group] and $row[date]

    Your queries are:
    $sql = "SELECT Name, Address, group, date FROM members WHERE Name = ".$_POST['zoekterm']." AND ID_GROUP = 11";
    and
    $sql = "UPDATE donatie SET VID = ". $row['Name']." WHERE nr =1";


  •  

    Posting Permissions

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