Ahoj. mam maly problem. potrebujem urobit system asi takto:
do policka napisem ID kod uzivatela a potvrdim. v tom sa mi nacita do formov jeho meno na editaciu. zmenim meno v inpute a odoslem a v SQL by sa mal vykonat update.
Po napisani ID a potvrdeni nenacita do pola meno, ale napise chybu:
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /server/web/px2.biz/htdocs/sub/wdesign/zmena.php on line 19
Mam to takto:
Zmena.php:
Kód:
<?php
mysql_connect(XXX, XXX, XXX);
mysql_select_db("web");
if (!$_POST['vyber']) {
echo("
Vyber:
<form action='zmena.php' method='post'>
<input type='text' name='id'>
<input type='submit' name='vyber'>
</form>"
);
}
if($_POST['vyber']) {
$_SESSION['id'] = $_POST['id'];
$result = mysql_query("SELECT * FROM web WHERE id=" . $_SESSION['id']);
while($row = mysql_fetch_object($result)) {
echo("
<form action='update.php' method=post>
<textarea name='meno'>" . $row -> text . "</textarea>
<input type='submit' name='sent'>
</form>"
);
}
}
?>
Update.php:
Kód:
<?php
mysql_connect(XXX, XXX, XXX);
mysql_select_db("web");
if(mysql_query("UPDATE web SET meno='" . $_POST['meno']. "' where id=" . $_SESSION['id']))
echo("Zmenene");
else
echo("Neuspesne");
?>