Document niet toegevoegd

Gestart doorDarksilk7 reacties44 weergaven

8 berichten · pagina 1 van 1

Darksilk

Lid · Topicstarter

Berichten
2
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb een script gevonden, alleen het werkt niet zo goed,
Hij geeft aan: Document niet toegevoegd.
hij hoort het naar de database te sturen
Spoiler tonen
ob_start();
error_reporting(0);
////////////////////////////////////////////////////////////////////
$sqlhost = "localhost"; // host MySQL
$sqlgebruikersnaam = "gebruikersnaam"; // gebruikersnaam MySQL
$sqlwachtwoord = "wachtwoord"; // wachtwoord MySQL
$sqldatabase = "database"; // database MySQL
////////////////////////////////////////////////////////////////////

$db = mysql_connect($sqlhost, $sqlgebruikersnaam, $sqlwachtwoord)
or die($message1 . mysql_error());
mysql_select_db("$sqldatabase");

?>

if ($_POST[submit] && $_POST[document])
{

$sql = "INSERT INTO documenten SET id = , bericht = " . $_POST[document] . "";

$res = mysql_query($sql);

if ($res)
{
echo "Document toegevoegd";
}
else
{
echo "Document niet toegevoegd";
}
}
elseif ($_POST[submit] || $_POST[document])
{
echo "Niet alle velden ingevult!";
}
else
{

echo "";
echo "";
echo "
echo "Document:";
echo "";

echo " ";

echo " ";

echo "";
echo "";
echo "";
}

?>

In het script zijn de database gegevens verwijdert, daardoor komt het niet.

Hopelijk kan iemand me helpen.
0
Berichten
3.532
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik help hem via teamviewer!
0
Darksilk

Lid · Topicstarter

Berichten
2
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wie kan mij helpen ? want is nog niet gelukt
0
Tgrm

Lid

Berichten
2.133
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Darksilk schreef:
Ik heb een script gevonden, alleen het werkt niet zo goed,
Hij geeft aan: Document niet toegevoegd.
hij hoort het naar de database te sturen
Spoiler tonen
ob_start();
error_reporting(0);
////////////////////////////////////////////////////////////////////
$sqlhost = "localhost"; // host MySQL
$sqlgebruikersnaam = "gebruikersnaam"; // gebruikersnaam MySQL
$sqlwachtwoord = "wachtwoord"; // wachtwoord MySQL
$sqldatabase = "database"; // database MySQL
////////////////////////////////////////////////////////////////////

$db = mysql_connect($sqlhost, $sqlgebruikersnaam, $sqlwachtwoord)
or die($message1 . mysql_error());
mysql_select_db("$sqldatabase");

?>

if ($_POST[submit] && $_POST[document])
{

$sql = "INSERT INTO documenten SET id = , bericht = " . $_POST[document] . "";

$res = mysql_query($sql);

if ($res)
{
echo "Document toegevoegd";
}
else
{
echo "Document niet toegevoegd";
}
}
elseif ($_POST[submit] || $_POST[document])
{
echo "Niet alle velden ingevult!";
}
else
{

echo "";
echo "";
echo "
echo "Document:";
echo "";

echo " ";

echo " ";

echo "";
echo "";
echo "";
}

?>

In het script zijn de database gegevens verwijdert, daardoor komt het niet.

Hopelijk kan iemand me helpen.

Ik was hier al eens voorbijgevlogen en zie nu pas wat een faalquery smile
$sql = "INSERT INTO documenten(id, bericht) VALUES(," . $_POST[document] . ")";


verder moet je volgens mij

if ($res)


veranderen in:

if (isset($res))


Hoop dat het werkt. biggrin
ps. Zet de volgende keer je script tussen
[code][/code]


tags ipv een spoiler. wink
0
Berichten
3.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Vind de spoiler ook wel chill anders... Dan kun je scrollen wanneer je wil en anders gewoon dichtklappen.
0
Berichten
5.957
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nee hoor, is niet goed. Code in spoiler mag wel.
0
Tgrm

Lid

Berichten
2.133
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Kyron schreef:
Vind de spoiler ook wel chill anders... Dan kun je scrollen wanneer je wil en anders gewoon dichtklappen.
Als ik dan een stukje code wil kopieren klapt hij dicht sadley
0
Berichten
28
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/ob_start"]ob_start[/URL][COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/error_reporting"]error_reporting[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #FF8000]////////////////////////////////////////////////////////////////////[/COLOR]
[COLOR= #0000BB]$sqlhost[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// host MySQL[/COLOR]
[COLOR= #0000BB]$sqlgebruikersnaam[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"gebruikersnaam"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// gebruikersnaam MySQL[/COLOR]
[COLOR= #0000BB]$sqlwachtwoord[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"wachtwoord"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// wachtwoord MySQL[/COLOR]
[COLOR= #0000BB]$sqldatabase[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"database"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// database MySQL
////////////////////////////////////////////////////////////////////[/COLOR]

[COLOR= #0000BB]$db[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sqlhost[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$sqlgebruikersnaam[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$sqlwachtwoord[/COLOR][COLOR= #007700])[/COLOR]
or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$message1[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"$sqldatabase"[/COLOR][COLOR= #007700]);[/COLOR]

?>

[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] [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]document[/COLOR][COLOR= #007700]]))[/COLOR] [COLOR= #FF8000]// Gebruik isset().[/COLOR]
[COLOR= #007700]{[/COLOR]

[COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"INSERT INTO documenten (bericht) VALUES ("[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]document[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]")"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Gebruik alsjeblieft mysql_num_rows, dat is veiliger[/COLOR]

[COLOR= #0000BB]$res[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$res[/COLOR][COLOR= #007700]))
{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Document toegevoegd"[/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]"Document niet toegevoegd"[/COLOR][COLOR= #007700];
}
}[/COLOR]
[URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]submit[/COLOR][COLOR= #007700]] || ![/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]document[/COLOR][COLOR= #007700]])[/COLOR] [COLOR= #FF8000]// wat als het niet goed verzonden is...[/COLOR]
[COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Niet alle velden ingevult!"[/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]"<center>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<table border="0" cellspacing="0" cellpadding="5" align="center">"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<form method="POST" action=""[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$PHP_SELF[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"">"[/COLOR][COLOR= #007700];[/COLOR]



[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<tr><td>Document:</td></tr>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<tr><td><input type="text" name="document"></td></tr>"[/COLOR][COLOR= #007700];[/COLOR]



[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<tr><td> </td></tr>"[/COLOR][COLOR= #007700];[/COLOR]





[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<tr><td><input type="submit" name="submit" value="Plaats!" class="buttons">&nbsp<input type="reset" value="Wis" class="buttons"></td></tr>"[/COLOR][COLOR= #007700];[/COLOR]


[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</form>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</table>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</center>"[/COLOR][COLOR= #007700];
}[/COLOR]

?>


Probeer dat eens, ik heb er hulp bijgezet wink
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