Page 1 of 1

update problem

Posted: Fri Aug 15, 2003 4:48 am
by zuzupus
hi,
i created 3 fields

<form action="dirmodify.php" method="post">
<tr>
<td> <input type="radio" name="ddir" value="<?=$r->sys_pk ?>" id="dir<?=$r->sys_pk ?>" /></td>
<td>Directory:&nbsp;</td>
<td><input type="text" name="name" size="20" /></td>
<td><input type="submit" name="modify" value="Modify"</td>
</tr>
</form>
this radio display some files from database when i select some file let say FORUM it display in text field and when i chnage the name to FORUM1 and submit the form its not at all updating name i dont no why

and in dirmodify.php

Code: Select all

<? $dir = './'; require($dir.'lib.php'); get_session(); ?>
<?
expire_header();
$ddir = $HTTP_POST_VARS['ddir']+0;
// modifying directories
         if ($modify && $ddir) {
   query_db_trad("UPDATE t_directories SET name = $name WHERE sys_pk = $ddir");//whats wrong in this query
           }
    
?>
thanks in advance

Posted: Fri Aug 15, 2003 5:03 am
by Wayne
are you sure its getting to the update command?

are you pushing enter to complete the form or are you clicking the submit button ... if you push enter the form does not return $modify!

Posted: Fri Aug 15, 2003 5:15 am
by zuzupus
i am clciking the button to submit the form and what should i do if user enters the form please guide me ,the function query_db_trad

function query_db_trad($arg, $errhandling = 'no') {
global $mysql;
$result = mysql_query($arg, $mysql);
if (!$result) {
if ($errhandling <> 'no') {
if (expire_header()) {
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"de\">
<head>
";
expire();
echo " <title>Datenbank-Fehler</title>
</head>
<body bgcolor=\"#ffffff\">
";
}
echo " <h1>Datenbank-Fehler</h1>
Die SQL-Datenbank meldete folgenden Fehler:<br />
Error ".mysql_errno($mysql).": ".htmlentities(mysql_error($mysql))."<br />
</body>
</html>
";
die();
}
}
return $result;
}

thanks in advance

Posted: Fri Aug 15, 2003 6:16 am
by Wayne
try putting in a simple echo statement before the query_db_trad() just to make sure it is actually getting into that if statement.

change

Code: Select all

query_db_trad("UPDATE t_directories SET name = $name WHERE sys_pk = $ddir");//whats wrong in this query
to

Code: Select all

query_db_trad("UPDATE t_directories SET name="$name" WHERE sys_pk="$ddir"");//whats wrong in this query

Posted: Fri Aug 15, 2003 6:22 am
by zuzupus
thank you very much its really appreciable :)