Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-10-2011, 09:34 AM   PM User | #1
elian
New to the CF scene

 
Join Date: Dec 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
elian is an unknown quantity at this point
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
elian is offline   Reply With Quote
Old 12-10-2011, 10:45 AM   PM User | #2
mindwin
New to the CF scene

 
Join Date: Dec 2011
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
mindwin is an unknown quantity at this point
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'";
mindwin is offline   Reply With Quote
Old 12-10-2011, 10:04 PM   PM User | #3
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,498
Thanks: 18
Thanked 361 Times in 360 Posts
sunfighter is on a distinguished road
$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";
sunfighter is online now   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:01 AM.


Advertisement
Log in to turn off these ads.