update mysql

Gestart doorKenzo3 reacties28 weergaven

4 berichten · pagina 1 van 1

Kenzo

Lid · Topicstarter

Berichten
1.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
heey iedereen,

ik ben met iets leuks bezig(vindt ik zelf)
en ga dat uiteindelijk gratis online zetten.

maar nu loop ik tegen een probleem.

zie:

[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]// hier include hij de config[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]config.php[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #FF8000]// haal de id uit database om te bewerken[/COLOR]
[COLOR= #0000BB]$haal[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM tabel WHERE id=$haal"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700])) {[/COLOR]
?>
<h2>Bewerk bericht</h2>
<form method="post" action="">
<table width="100%">
<tr>
  <td align="left">Door</td>
  <td align="left"><input name="naam" id="Naam" value="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]Naam[/COLOR][COLOR= #007700]];[/COLOR] ?>" /></td>
</tr>
<tr>
  <td align="left">Bericht:</td> 
  <td align="left"><textarea name="bericht" rows="10" cols="20" id="Bericht"/>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]Bericht[/COLOR][COLOR= #007700]];[/COLOR] ?></textarea></td>
</tr>

<tr>
  <td align="left"><input type="submit" name="submit" value="Bewerk" /></td>
</tr>
</table>
</form>
[COLOR= #0000BB]<?php[/COLOR]


[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]))
{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"geen naam"[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]))
{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"geen bericht"[/COLOR][COLOR= #007700];
}[/COLOR]

[URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE tabel
    SET
        Bericht = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]",
        Naam = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]",
        NOW()

    WHERE id = $haal"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Bericht Succesvol bewerkt!"[/COLOR][COLOR= #007700];
}[/COLOR]


?>

[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]}[/COLOR]
?>


zoals je ziet, niet bepaald veilig.
er komt bij de $_POST nog mysql_real_escape_string() bij maar dat is nu nog even niet belangrijk.
en misschien kan ik beter een isset gebruiken bij de if en elseif
mijn vraag is dus nu: Waarom UPDATE hij de tabel niet?
aan de config kan het niet liggen want ik kan wel toevoegen
ik hoop dat iemand het weet(vast wel)smile
groeten
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Je hebt
Naam = blabla,
NOW()
Bij die nou zeg je niet wat ie moet updaten
0
Kenzo

Lid · Topicstarter

Berichten
1.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
oke, nouja dat zou dan Tijd = NOW() moeten zijn..
dat heb ik al een x geprobeerd en daarna meerdere dingen veranderd.
maar ik ga het nog een keer proberen want jij zegt het dusjasmile
EDIT: ÀœBER bedankt!smileals je er iets voor wilt hoort hoor ik het welsmile
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Als je me wat wilt geven dan graag santabaard
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren