php zet niets in database

Gestart doorJordyvc6 reacties38 weergaven

7 berichten · pagina 1 van 1

Jordyvc

Lid · Topicstarter

Berichten
6.037
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hey,

Waarom zet dit script niets in de database?

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]config.php[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]]==[/COLOR][COLOR= #DD0000]"POST"[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO product (id, naam, prijs, beschrijving, afbeelding)
            VALUES
            ("[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]","[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]","[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]beschrijving[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]","[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]afbeelding[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]")"[/COLOR][COLOR= #007700]);

}[/COLOR]
[URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<form action= method=POST>"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Naam: <input type=text name=naam /><br />"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Prijs <input type=text name=prijs />(enkel een getal)<br />"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Beschrijving <textarea name=beschrijving rows=4 cols=20></textarea><br />"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Afbeelding <input type=text name=afbeelding />(URL bv. http://voorbeeld.be/plaatsje.png)<br />"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<input type=submit value=toevoegen />"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</form>"[/COLOR][COLOR= #007700];
}[/COLOR]
?>


Mvg,
Jordyvc
0
Berichten
9.953
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Foutafhandeling. Zorg eerst eens dat dat er is. Als dat er is kom je al gelijk verder.
0
Jordyvc

Lid · Topicstarter

Berichten
6.037
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]config.php[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]]==[/COLOR][COLOR= #DD0000]"POST"[/COLOR][COLOR= #007700]) {[/COLOR]
[COLOR= #0000BB]$post[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO product (id, naam, prijs, beschrijving, afbeelding)
            VALUES
            ("[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]","[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]","[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]beschrijving[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]","[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]afbeelding[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]")"[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$post[/COLOR][COLOR= #007700]) {[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"kan niets toevoegen aan de database!"[/COLOR][COLOR= #007700];
}
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<form action= method=POST>"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Naam: <input type=text name=naam /><br />"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Prijs <input type=text name=prijs />(enkel een getal)<br />"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Beschrijving <textarea name=beschrijving rows=4 cols=20></textarea><br />"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Afbeelding <input type=text name=afbeelding />(URL bv. http://voorbeeld.be/plaatsje.png)<br />"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<input type=submit value=toevoegen />"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</form>"[/COLOR][COLOR= #007700];
}[/COLOR]
?>


Zoiets dan?
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Vergeet mysql_error() niet...
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
je hebt voor VALUES 5 velden tussen de haakjes, en na VALUES staan er maar 4 waarden gegeven in je query..
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Gebruik daarom enters in je querie. Dan wordt het beter leesbaarer en heb je meer overzicht.
0
Jordyvc

Lid · Topicstarter

Berichten
6.037
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ah ja, dus gwn elke keer onder elkaar zetten? Ja lijkt me ook wel duidelijker dan zo naast elkaar. Bedankt voor de tip! smile
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