php fout of fout van wamp

Gestart doorFreestyle12 reacties14 weergaven

13 berichten · pagina 1 van 1

Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb een error maar ik snap hem niet helemaal.

Error:

Notice: Undefined index: naam in C:wampwww	icketadminsettings.php on line 26


regel 26 is regel 2 hier onder.

Code:

[COLOR= #0000BB]<?php
$naam[/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= #0000BB]$link[/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]link[/COLOR][COLOR= #007700]]);[/COLOR]
?>
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dan bestaat de key naam niet in de $_POST array. Oftewel, dan bestaat $_POST[naam] niet
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Maar ik heb in de zelfde pagina:


Staan. dan licht het dus aan wamp???
Weet jij dan misschien hoe ik deze error warning weg kan halen.
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Je voert waarschijnlijk dat stukje code uit nog voor er iets gepost is. Daarom bestaat $_POST[naam] niet.

Op te lossen door

if(isset($_POST[naam])) { blablabla }


te doen.
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nee, want in de database staat al wel iets.
Bij de php info staat ook:
display_errors On On

Moet dat dan misschien off zijn?
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dat er al in de database staat is iets anders dan dat er al gepost wordt...
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oo, ja maar wat er in de database staat word ook weer geven in dat form. Bij value.
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ja, maar je hebt het formulier nog niet verzonden. Het script kan niet weten wat je wilt gaan sturen..
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Maar hoe los ik dit dan op? Moet ik dan die error uit zetten in php??
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nee, je moet wat meer code geven die de $_POST verwerkt
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Code:
Spoiler tonen
[COLOR= #0000BB]<?php
$naam[/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][URL="http://www.php.net/link"]link[/URL] [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]link[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$versie[/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]versie[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$online[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Y-m-d"[/COLOR][COLOR= #007700]));[/COLOR] 

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]opnieuw[/COLOR][COLOR= #007700]])) 
                    {[/COLOR]
                        ?>
                        <strong>Weet je zeker dat je de begin datum van de website wilt veranderen naar nu?</strong>
                        <input method="GET" type="checkbox" name="zeker" value="ja" />Ja, ik weet het zeker.
                        [COLOR= #0000BB]<?php[/COLOR]
                        [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]zeker[/COLOR][COLOR= #007700]]))
                        {[/COLOR]
                            [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO settings (web.naam, web.link, web.online, web.version)
                                          VALUES ("[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$naam[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]", "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$link[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]", "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$online[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]", "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$versie[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]")
                                        "[/COLOR][COLOR= #007700]);[/COLOR]
                            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"De datum is succes vol geupdate. Heeft u spijd, dan kunt u het in de database terug zetten."[/COLOR][COLOR= #007700];
                        }
                    }[/COLOR]
?>

<form action="#" method="POST">
                        <table>
                            <tr>
                                <th width="25%">Website naam:</th>
                                <td><input type="text" name="naam" value="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$fetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]web.naam[/COLOR][COLOR= #007700]];[/COLOR] ?>" /></td>
                            </tr>
                            <tr>
                                <th>Website link:</th>
                                <td><input type="text" name="link" value="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$fetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]web.link[/COLOR][COLOR= #007700]];[/COLOR] ?>" /></td>
                            </tr>
                                <tr>
                                <th>Versie:</th>
                                <td><input type="text" name="versie" value="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$fetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]web.version[/COLOR][COLOR= #007700]];[/COLOR] ?>" /></td>
                            </tr>
                           </table>
                        <table border="1px" cellspacing="1">
                            <tr>
                                <th>Website online: 
                                    <input type="submit" name="opnieuw" value="Refresh" /> De opening van de website word hier vernieuwt.
                                   </th>
                            </tr>
                            <tr>
                                <th>Settings wijzigen:
                                    <input type="submit" name="wijzig" value="Wijzig" /> Wijzig de settings
                                   </th>
                            </tr>
                           
                        </table>
                    </form>
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Wat ik zei was dus wel zo..

Maar zo voorkom je het:

if($_SERVER[REQUEST_METHOD] == "POST")
{
$naam = mysql_real_escape_string($_POST[naam]);
&link = mysql_real_escape_string($_POST[link]);
$versie = mysql_real_escape_string($_POST[versie]);
$online = mysql_real_escape_string(date("Y-m-d"));
}
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Bedankt! Het werkt.
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