update problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
zuzupus
Forum Commoner
Posts: 70
Joined: Thu Jul 17, 2003 4:54 am

update problem

Post 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
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post 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!
zuzupus
Forum Commoner
Posts: 70
Joined: Thu Jul 17, 2003 4:54 am

Post 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
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post 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
zuzupus
Forum Commoner
Posts: 70
Joined: Thu Jul 17, 2003 4:54 am

Post by zuzupus »

thank you very much its really appreciable :)
Post Reply