-Onderaan de pagina kijken-
Fout in forum
<a href="?i=[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000][/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$gegevens[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000][/COLOR][COLOR= #007700];[/COLOR] ?>" target="_blank"> @pchooligan, Milan had me al geholpen, maar toch bedankt, er staat een nieuwe vraag...
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]config.php[/COLOR][COLOR= #007700];[/COLOR]
?>
<HTML>
<HEAD>
<TITLE>MyWebbles</TITLE>
<LINK HREF="style.css" TYPE="text/css" REL="stylesheet">
</HEAD>
<BODY>
[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]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]submit[/COLOR][COLOR= #007700]])) {[/COLOR]
[COLOR= #0000BB]$res[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT MAX(id) FROM categories"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$res[/COLOR][COLOR= #007700])) {[/COLOR]
[COLOR= #0000BB]$id[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_result"]mysql_result[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$res[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) +[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700];
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[COLOR= #FF8000]// er waren blijkbaar nog geen categorieen[/COLOR]
[COLOR= #0000BB]$id[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];
}[/COLOR]
?> -De beste PHPer van dit forum heeft weer een probleem
-
Ik wil dus dat hij dit in de data insert:
Bij $naam moet het dus uitgevoerd worden:
Hoe kan ik dat doen?
-Ik wil dus dat hij dit in de data insert:
[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]". $get_userdata [[/COLOR]naam[COLOR= #DD0000]] ."[/COLOR][COLOR= #007700];[/COLOR] ?> Bij $naam moet het dus uitgevoerd worden:
$titel = htmlentities($_POST[titel]);
$naam = -hier moet bovenstaande uitkomst komen-
$datum = time();
$email = htmlentities($_POST[email]);
$bericht = htmlentities($_POST[bericht]); Hoe kan ik dat doen?
[COLOR= #0000BB]<?php
$titel[/COLOR] [COLOR= #007700]=[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$naam[/COLOR] [COLOR= #007700]=[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$get_userdata[/COLOR] [COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$datum[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/time"]time[/URL][COLOR= #007700]();[/COLOR]
[COLOR= #0000BB]$email[/COLOR] [COLOR= #007700]=[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$bericht[/COLOR] [COLOR= #007700]=[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]);[/COLOR]
?> zoiets?
In de database staat de naam er niet, moet hij niet geechot worden?
Normaal gesproken niet.
Werkt dit:
wel?
Als dat niet werkt, zet dan aub je query hier even neer
Werkt dit:
[COLOR= #0000BB]<?php
$titel[/COLOR] [COLOR= #007700]=[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$naam[/COLOR] [COLOR= #007700]=[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$get_userdata[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$datum[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/time"]time[/URL][COLOR= #007700]();[/COLOR]
[COLOR= #0000BB]$email[/COLOR] [COLOR= #007700]=[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$bericht[/COLOR] [COLOR= #007700]=[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]);[/COLOR]
?> wel?
Als dat niet werkt, zet dan aub je query hier even neer
Hier query(en nog andere dingetjes):
if(trim($_POST[titel]) == "") $error = "Je moet een titel invullen<BR><BR>";
elseif(trim($_POST[bericht]) == "") $error = "Je moet een bericht invullen<BR><BR>";
if (!$error) {
$titel = htmlentities($_POST[titel]);
$naam = htmlentities($get_userdata[naam]);
$datum = time();
$email = htmlentities($_POST[email]);
$bericht = htmlentities($_POST[bericht]);
$query = "INSERT INTO forum (id, titel, cat, naam, datum, email, bericht, hits)
VALUES (, $titel, $cat, $naam, $datum, $email, $bericht, 0)";
mysql_query($query) or die(mysql_error()); word $get_userdata voor of na de query opgehaald?
Voor, in de config.php die bovenin geincluded word
Kun je dan even de rest van de code posten?
ok:
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"config.php"[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$cat[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]cat[/COLOR][COLOR= #007700]];[/COLOR]
?>
<HTML>
<HEAD>
<TITLE>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$forumname[/COLOR][COLOR= #007700];[/COLOR] ?></TITLE>
<LINK HREF="style.css" TYPE="text/css" REL="stylesheet">
</HEAD>
<BODY>
[COLOR= #0000BB]<?php
$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT naam FROM categories WHERE id=$cat"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"q: "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<CENTER>De geselecteerde categorie bestaat niet (meer).<BR>n"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<A HREF="categorieen.php">Terug naar Categorieën</A><BR></CENTER>n"[/COLOR][COLOR= #007700];
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$naam[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_result"]mysql_result[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"naam"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/mysql_free_result"]mysql_free_result[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<A HREF="categorieen.php">"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$forumname[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"</A> > "[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<A HREF="forum.php?cat="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$cat[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"">"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$naam[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"</A> > <B>Nieuw bericht</B><BR>n"[/COLOR][COLOR= #007700];[/COLOR]
?>
<BR>
<TABLE WIDTH="500" BORDER="1" CELLSPACING="0" CELLPADDING="2">
<TR>
<TD WIDTH="500" ALIGN="center">
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]submit[/COLOR][COLOR= #007700]]) {[/COLOR]
[COLOR= #0000BB]$error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/trim"]trim[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]]) ==[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] [COLOR= #0000BB]$error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"Je moet een titel invullen<BR><BR>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/trim"]trim[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]) ==[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] [COLOR= #0000BB]$error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"Je moet een bericht invullen<BR><BR>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$error[/COLOR][COLOR= #007700]) {[/COLOR]
[COLOR= #0000BB]$titel[/COLOR] [COLOR= #007700]=[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$naam[/COLOR] [COLOR= #007700]=[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$get_userdata[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$datum[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/time"]time[/URL][COLOR= #007700]();[/COLOR]
[COLOR= #0000BB]$email[/COLOR] [COLOR= #007700]=[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$bericht[/COLOR] [COLOR= #007700]=[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"INSERT INTO forum (id, titel, cat, naam, datum, email, bericht, hits)
VALUES (, $titel, $cat, $naam, $datum, $email, $bericht, 0)"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Het bericht is verzonden.<BR>n"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"klik <A HREF="forum.php?cat="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$cat[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"">hier</A> om terug naar het forum te gaan.<BR>n"[/COLOR][COLOR= #007700];
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[COLOR= #FF8000]// errors [/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<B>"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$error[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"</B><BR>n"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<FORM ACTION=""[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]PHP_SELF[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]"?cat="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$cat[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"" METHOD="post">n"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<INPUT TYPE="submit" VALUE="Terug">n"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</FORM>"[/COLOR][COLOR= #007700];
}
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
?>
<TABLE CLASS="tf" WIDTH="500" BORDER="0" CELLSPACING="0" CELLPADDING="2">
<FORM ACTION="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]PHP_SELF[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]"?cat="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$cat[/COLOR][COLOR= #007700];[/COLOR] ?>" METHOD="post">
<TR>
<TD CLASS="tf" WIDTH="125" ALIGN="right"><B>Titel</B> </TD>
<TD CLASS="tf" WIDTH="375"><INPUT TYPE="text" CLASS="def" NAME="titel" SIZE="30" MAXLENGTH="50"></TD>
</TR>
<TR>
<TD CLASS="tf" WIDTH="125" ALIGN="right" VALIGN="top"><B>Bericht</B> </TD>
<TD CLASS="tf" WIDTH="375"><TEXTAREA NAME="bericht" CLASS="def" COLS="30" ROWS="4"></TEXTAREA><BR></TD>
</TR>
<TR>
<TD CLASS="tf" WIDTH="500" COLSPAN="2" ALIGN="center">
<INPUT TYPE="submit" CLASS="def" NAME="submit" VALUE="Post topic">
</TD>
</TR>
</FORM>
</TABLE>
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]}[/COLOR] [COLOR= #FF8000]// einde else[/COLOR]
?>
<BR>
</TD>
</TR>
<TR>
<TD WIDTH="500" ALIGN="center"><A HREF="forum.php?cat=[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$cat[/COLOR][COLOR= #007700];[/COLOR] ?>">Terug naar Forum</A></TD>
</TR>
</TABLE>
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]}[/COLOR] [COLOR= #FF8000]// einde check[/COLOR]
?>
</BODY>
</HTML> boven
staat
, dat zou het probleem kunnen zijn (not sure)
$naam = htmlentities($get_userdata[naam]); staat
$naam = mysql_result($query, 0, "naam"); , dat zou het probleem kunnen zijn (not sure)
Dat zie ik niet?...