...

View Full Version : update does not work



elian
12-10-2011, 09:34 AM
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.



<?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

mindwin
12-10-2011, 10:45 AM
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.



$sql = "UPDATE donatie SET VID = '".$row[Name]."' WHERE nr ='1'";

sunfighter
12-10-2011, 10:04 PM
$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";



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum