missing; before statement
zie ook http://www.phphulp.nl/php/forum/topic/data-wordt-niet-ingevoegd-in-de-tabel/75403/last/
Maar heb nu wat anders wat daar wel bij hoort en dat is dat FF deze melding geeft.
Fout: missing ; before statement
Bronbestand:
Regel: 1, Kolom: 133
Broncode:
minichat(document.getElementById('chattext').value); document.getElementById('chattext').value = ''; document.getElementById('naam').value); return false;
Het gaat nu om de v van document.getElementById('naam').v<--->deze is het-->alue; return false;
Heb al rond gezocht op google maar kom er niet uit. misschien iemand van jullie wel.
Met vriendelijke groet
Het afsluithaakje na "value" wordt nergens geopend volgend mij?
maar als ik dat haakje in het begin plaats dan krijg ik de foutmelding niet
dus dat is goed. Maar dan post ie niks naar de DB toe haal ik het haakje weg
dan foutmelding, en wel een post naar de DB toe
Verkeerd gelezen!
Gewijzigd op 03/01/2011 19:56:53 door Bas Cost Budde
Als er een javascript fout optreedt dan luister je browser niet meer naar de onsubmit en submit hij de form sowieso. Als je geen javascript fout hebt zal hij kijken naar de return waarde van je onsubmit functie die dus false is.
Als ik anders doe dan foutmelding wel post maar anders is het geen foutmelding en geen post.
Hoe kan ik ervoor zorgen dat dit
Code (php)
1
2
3
4
5
2
3
4
5
<form method="post" onsubmit="minichat(document.getElementById('chattext').value); document.getElementById('chattext').value = ''; document.getElementById('naam').value, document.getElementById('naam').value = ''; return true;">
Naam: <input class="mytext" id="naam" type="tekst" name="naam"/>
<input class="mytext" id="chattext" type="tekst" name="chat"/>
<input type="submit" name="verzend" value="Chatten" />
</form>
Naam: <input class="mytext" id="naam" type="tekst" name="naam"/>
<input class="mytext" id="chattext" type="tekst" name="chat"/>
<input type="submit" name="verzend" value="Chatten" />
</form>
Ook helemaal verstuurd wordt met die onsubmit?
Alvast bedankt voor het meedenken
Gewijzigd op 03/01/2011 20:08:19 door thomas de vries
Post eens een volledig script of zip deze? Dan wil ik wel eventjes voor je kijken :)
Ja maar daar zitten ook een aantal fouten in die je waarschijnlijk in je recentste versie verbeterd hebt. Ik ga die fouten niet opnieuw voor je debuggen want dat is zonde van de tijd. Post gewoon de meest actuele versie.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>chatten</title>
<script type="text/javascript" src="/js/editor.js"></script>
<script src="/js/prototype.js" type="text/javascript"></script>
<script language="JavaScript">
function setsmiley(what){
tmp=document.getElementById("chattext");
tmp.value = tmp.value+" "+what+" ";
tmp.focus();
}
</script>
<script type="text/javascript">
// <![CDATA[
var form_name = 'postform';
var text_name = 'chattext';
var load_draft = false;
var upload = false;
// Define the bbCode tags
var bbcode = new Array();
var bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','','','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]','[flash=]', '[/flash]','[size=]','[/size]');
var imageTag = false;
// Helpline messages
var help_line = {
b: 'Bold text: [b]text[/b]',
i: 'Italic text: [i]text[/i]',
u: 'Underline text: [u]text[/u]',
q: 'Quote text: [quote]text[/quote] or [quote="name"]text[/quote]',
c: 'Code display: code',
l: 'List: [list]text[/list]',
o: 'Ordered list: [list=]text[/list]',
p: 'Insert image: [img]http://image_url[/img]',
w: 'Insert URL: [url]http://url[/url] or [url=http://url]URL text[/url]',
a: 'Inline uploaded attachment: [attachment=]filename.ext[/attachment]',
s: 'Font colour: [color=red]text[/color] Tip: you can also use color=#FF0000',
f: 'Font size: [size=85]small text[/size]',
e: 'List: Add list element',
d: 'Flash: [flash=width,height]http://url[/flash]'
}
// ]]>
</script>
<style type="text/css">
#prototype {
display: none;
}
#chatwindow {
margin-left:15px;
left:0px;
top:0px;
width:500px;
height:450px;
border-collapse:collapse;
background-color:#999;
}
#ubb {
margin-left:15px;
top:360px;
left:10px;
width:500px;
height:31px;
}
#chatten {
margin-left:15px;
top:360px;
width:500px;
height:60px;
}
.mytext
{
width:100%;
margin-bottom:10px;
background-color: #999;
border:#000;
}
</style>
</head>
<body>
<div id="chatwindow">
<table width="100%">
<tr>
<td bgcolor="" height="" valign="top"><?php include("chat1.php"); var_dump($_POST); ?></td>
</tr>
</table>
</div>
<div id="ubb">
<a href="javascript:setsmiley(':)')"><img src="/images/smilies/icon_smile.gif" border="0" alt=":)" align="bottom"></a>
<a href="javascript:setsmiley(':D')"><img src="/images/smilies/icon_biggrin.gif" border="0" alt=":D" align="bottom"></a>
<a href="javascript:setsmiley(':P')"><img src="/images/smilies/icon_tongue.gif" border="0" alt=":p" align="bottom"></a>
<a href="javascript:setsmiley(':(')"><img src="/images/smilies/icon_sad.gif" border="0" alt=":(" align="bottom"></a>
<a href="javascript:setsmiley('8)')"><img src="/images/smilies/icon_cool.gif" border="0" alt="8)" align="bottom"></a>
<a href="javascript:setsmiley('LOL')"><img src="/images/smilies/icon_lol.gif" border="0" alt="LOL" align="bottom"></a>
<a href="javascript:setsmiley(':@')"><img src="/images/smilies/icon_mad.gif" border="0" alt=":@" align="bottom"></a>
<a href="javascript:setsmiley(':o')"><img src="/images/smilies/icon_surprised.gif" border="0" alt=":o" align="bottom"></a>
<a href="javascript:setsmiley('*-)')"><img src="/images/smilies/icon_rolleyes.gif" border="0" alt="*-" align="bottom"></a>
<a href="javascript:setsmiley('[-)')"><img src="/images/smilies/icon_sleep.gif" border="0" alt="[-" align="bottom"></a>
<a href="javascript:setsmiley('8-)')"><img src="/images/smilies/icon_unsure.gif" border="0" alt="8-" align="bottom"></a>
<a href="javascript:setsmiley(':S')"><img src="/images/smilies/icon_wacko.gif" border="0" alt=":s" align="bottom"></a>
<a href="javascript:setsmiley(';)')"><img src="/images/smilies/icon_wink.gif" border="0" alt=";)" align="bottom"></a>
<a href="javascript:setsmiley('(l)')"><img src="/images/smilies/icon_wub.gif" border="0" alt="(l)" align="bottom"></a>
<input type="button" name="b" value="B" style="font-weight:bold; width: 30px; background-color:#666" onclick="bbstyle(0)" title="Bold text: [b]text[/b]" />
<input type="button" class="button" accesskey="i" name="addbbcode2" value=" i " style="font-style:italic; width: 30px; background-color:#666" onclick="bbstyle(2)" title="Italic text:
[i]text[/i]" />
<input type="button" class="button" accesskey="u" name="addbbcode4" value=" u " style="text-decoration: underline; width: 30px; background-color:#666" onclick="bbstyle(4)" title=
"Underline text: [u]text[/u]" />
<input type="button" class="button" accesskey="q" name="addbbcode6" value="Quote" style="width: 50px; background-color:#666" onclick="bbstyle(6)" title='Quote text:
[quote]text[/quote]or [quote="name"]text[/quote]' />
</div><br />
<div id="chatten">
<form method="post" onsubmit="
minichat(document.getElementById('chattext').value),
document.getElementById('chattext').value = '';
(document.getElementById('naam').value),
document.getElementById('naam').value = '';
return false;
">
Naam: <input class="mytext" id="naam" type="tekst" name="naam"/>
<input class="mytext" id="chattext" type="tekst" name="chat"/>
<input type="submit" name="verzend" value="Chatten" />
</form>
</div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>chatten</title>
<script type="text/javascript" src="/js/editor.js"></script>
<script src="/js/prototype.js" type="text/javascript"></script>
<script language="JavaScript">
function setsmiley(what){
tmp=document.getElementById("chattext");
tmp.value = tmp.value+" "+what+" ";
tmp.focus();
}
</script>
<script type="text/javascript">
// <![CDATA[
var form_name = 'postform';
var text_name = 'chattext';
var load_draft = false;
var upload = false;
// Define the bbCode tags
var bbcode = new Array();
var bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','','','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]','[flash=]', '[/flash]','[size=]','[/size]');
var imageTag = false;
// Helpline messages
var help_line = {
b: 'Bold text: [b]text[/b]',
i: 'Italic text: [i]text[/i]',
u: 'Underline text: [u]text[/u]',
q: 'Quote text: [quote]text[/quote] or [quote="name"]text[/quote]',
c: 'Code display: code',
l: 'List: [list]text[/list]',
o: 'Ordered list: [list=]text[/list]',
p: 'Insert image: [img]http://image_url[/img]',
w: 'Insert URL: [url]http://url[/url] or [url=http://url]URL text[/url]',
a: 'Inline uploaded attachment: [attachment=]filename.ext[/attachment]',
s: 'Font colour: [color=red]text[/color] Tip: you can also use color=#FF0000',
f: 'Font size: [size=85]small text[/size]',
e: 'List: Add list element',
d: 'Flash: [flash=width,height]http://url[/flash]'
}
// ]]>
</script>
<style type="text/css">
#prototype {
display: none;
}
#chatwindow {
margin-left:15px;
left:0px;
top:0px;
width:500px;
height:450px;
border-collapse:collapse;
background-color:#999;
}
#ubb {
margin-left:15px;
top:360px;
left:10px;
width:500px;
height:31px;
}
#chatten {
margin-left:15px;
top:360px;
width:500px;
height:60px;
}
.mytext
{
width:100%;
margin-bottom:10px;
background-color: #999;
border:#000;
}
</style>
</head>
<body>
<div id="chatwindow">
<table width="100%">
<tr>
<td bgcolor="" height="" valign="top"><?php include("chat1.php"); var_dump($_POST); ?></td>
</tr>
</table>
</div>
<div id="ubb">
<a href="javascript:setsmiley(':)')"><img src="/images/smilies/icon_smile.gif" border="0" alt=":)" align="bottom"></a>
<a href="javascript:setsmiley(':D')"><img src="/images/smilies/icon_biggrin.gif" border="0" alt=":D" align="bottom"></a>
<a href="javascript:setsmiley(':P')"><img src="/images/smilies/icon_tongue.gif" border="0" alt=":p" align="bottom"></a>
<a href="javascript:setsmiley(':(')"><img src="/images/smilies/icon_sad.gif" border="0" alt=":(" align="bottom"></a>
<a href="javascript:setsmiley('8)')"><img src="/images/smilies/icon_cool.gif" border="0" alt="8)" align="bottom"></a>
<a href="javascript:setsmiley('LOL')"><img src="/images/smilies/icon_lol.gif" border="0" alt="LOL" align="bottom"></a>
<a href="javascript:setsmiley(':@')"><img src="/images/smilies/icon_mad.gif" border="0" alt=":@" align="bottom"></a>
<a href="javascript:setsmiley(':o')"><img src="/images/smilies/icon_surprised.gif" border="0" alt=":o" align="bottom"></a>
<a href="javascript:setsmiley('*-)')"><img src="/images/smilies/icon_rolleyes.gif" border="0" alt="*-" align="bottom"></a>
<a href="javascript:setsmiley('[-)')"><img src="/images/smilies/icon_sleep.gif" border="0" alt="[-" align="bottom"></a>
<a href="javascript:setsmiley('8-)')"><img src="/images/smilies/icon_unsure.gif" border="0" alt="8-" align="bottom"></a>
<a href="javascript:setsmiley(':S')"><img src="/images/smilies/icon_wacko.gif" border="0" alt=":s" align="bottom"></a>
<a href="javascript:setsmiley(';)')"><img src="/images/smilies/icon_wink.gif" border="0" alt=";)" align="bottom"></a>
<a href="javascript:setsmiley('(l)')"><img src="/images/smilies/icon_wub.gif" border="0" alt="(l)" align="bottom"></a>
<input type="button" name="b" value="B" style="font-weight:bold; width: 30px; background-color:#666" onclick="bbstyle(0)" title="Bold text: [b]text[/b]" />
<input type="button" class="button" accesskey="i" name="addbbcode2" value=" i " style="font-style:italic; width: 30px; background-color:#666" onclick="bbstyle(2)" title="Italic text:
[i]text[/i]" />
<input type="button" class="button" accesskey="u" name="addbbcode4" value=" u " style="text-decoration: underline; width: 30px; background-color:#666" onclick="bbstyle(4)" title=
"Underline text: [u]text[/u]" />
<input type="button" class="button" accesskey="q" name="addbbcode6" value="Quote" style="width: 50px; background-color:#666" onclick="bbstyle(6)" title='Quote text:
[quote]text[/quote]or [quote="name"]text[/quote]' />
</div><br />
<div id="chatten">
<form method="post" onsubmit="
minichat(document.getElementById('chattext').value),
document.getElementById('chattext').value = '';
(document.getElementById('naam').value),
document.getElementById('naam').value = '';
return false;
">
Naam: <input class="mytext" id="naam" type="tekst" name="naam"/>
<input class="mytext" id="chattext" type="tekst" name="chat"/>
<input type="submit" name="verzend" value="Chatten" />
</form>
</div>
</body>
</html>
chat1.php
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
session_start();
ini_set('display_errors', 'On');
error_reporting(E_ALL);
//include("ubb.php");
//Database verbinding
$mysqli = new mysqli('localhost','root','******','*******');
if(mysqli_connect_errno())
{
trigger_error('Fout bij verbinden: '.$mysqli->error);
}
//de select maken
if($_SERVER['REQUEST_METHOD'] == "POST")
{
if($_POST['text'] == "")
{
echo '';
}
else
{
$chat = $_POST['text'];
$login = $_POST['login'];
$sql_insert = "INSERT INTO chat (id,user,tekst,datum) VALUES (NULL, '".$login."', '".$chat."',NOW())";
if(!$res = $mysqli->query($sql_insert))
{
trigger_error('Error! '.$mysqli->error);
}
}
}
$sql = "SELECT * FROM chat ORDER BY id DESC LIMIT 10";
if(!$res = $mysqli->query($sql))
{
echo '<tr><td class="menuLink" colspan="7">Er is een fout geconstateerd in het script! Er is automatisch een mail verstuurd naar de beheerder.
Onze excuses voor het ongemak.</td></tr>';
mail($mail,"The-undergrounds bug report","Er is een fout gevonden ".$mysqli->error."","From: The-undergrounds <[email protected]>\n");
}
else
{
echo '<table width="50%">';
//De output
var_dump($_POST);
while($row = $res->fetch_assoc())
{
echo '
<tr>
<td class="menuLink" width="20%"><a href="/profiel/'.$row['user'].'">'.$row['user'].':</td>
<td class="menuLink" width="75%">'.$row['tekst'].'<br />'.var_dump($_POST).'</td>
</tr>';
}
echo '</table>';
}
?>
<div id="prototype"></div>
<script type="text/javascript">
function minichat(text) {
window.clearTimeout(t);
new Ajax.Updater('chatwindow', '/pages/chat1.php', {
method: 'post',
requestTimeout: 5,
parameters: { text: text },
evalScripts: true
});
}
var t = false;
t = window.setTimeout('minichat()', 5000000000);
</script>
session_start();
ini_set('display_errors', 'On');
error_reporting(E_ALL);
//include("ubb.php");
//Database verbinding
$mysqli = new mysqli('localhost','root','******','*******');
if(mysqli_connect_errno())
{
trigger_error('Fout bij verbinden: '.$mysqli->error);
}
//de select maken
if($_SERVER['REQUEST_METHOD'] == "POST")
{
if($_POST['text'] == "")
{
echo '';
}
else
{
$chat = $_POST['text'];
$login = $_POST['login'];
$sql_insert = "INSERT INTO chat (id,user,tekst,datum) VALUES (NULL, '".$login."', '".$chat."',NOW())";
if(!$res = $mysqli->query($sql_insert))
{
trigger_error('Error! '.$mysqli->error);
}
}
}
$sql = "SELECT * FROM chat ORDER BY id DESC LIMIT 10";
if(!$res = $mysqli->query($sql))
{
echo '<tr><td class="menuLink" colspan="7">Er is een fout geconstateerd in het script! Er is automatisch een mail verstuurd naar de beheerder.
Onze excuses voor het ongemak.</td></tr>';
mail($mail,"The-undergrounds bug report","Er is een fout gevonden ".$mysqli->error."","From: The-undergrounds <[email protected]>\n");
}
else
{
echo '<table width="50%">';
//De output
var_dump($_POST);
while($row = $res->fetch_assoc())
{
echo '
<tr>
<td class="menuLink" width="20%"><a href="/profiel/'.$row['user'].'">'.$row['user'].':</td>
<td class="menuLink" width="75%">'.$row['tekst'].'<br />'.var_dump($_POST).'</td>
</tr>';
}
echo '</table>';
}
?>
<div id="prototype"></div>
<script type="text/javascript">
function minichat(text) {
window.clearTimeout(t);
new Ajax.Updater('chatwindow', '/pages/chat1.php', {
method: 'post',
requestTimeout: 5,
parameters: { text: text },
evalScripts: true
});
}
var t = false;
t = window.setTimeout('minichat()', 5000000000);
</script>
Het gaat alleen maar om de <form method="post"> gedeelte
Hij verstuurd de chattext wel maar niet de naam.
Gewijzigd op 03/01/2011 23:43:13 door thomas de vries
Ik zou het dan minstens zo doen:
Code (php)
1
2
3
4
5
6
7
2
3
4
5
6
7
<form method="post" onsubmit="
minichat(document.getElementById('chattext').value,
document.getElementById('naam').value);
document.getElementById('chattext').value = '';
document.getElementById('naam').value = '';
return false;
">
minichat(document.getElementById('chattext').value,
document.getElementById('naam').value);
document.getElementById('chattext').value = '';
document.getElementById('naam').value = '';
return false;
">
PHP
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
<script type="text/javascript">
function minichat(text,name) {
window.clearTimeout(t);
new Ajax.Updater('chatwindow', '/pages/chat1.php', {
method: 'post',
requestTimeout: 5,
parameters: { text: text, name: name },
evalScripts: true
});
}
var t = false;
t = window.setTimeout('minichat()', 5000000000);
</script>
function minichat(text,name) {
window.clearTimeout(t);
new Ajax.Updater('chatwindow', '/pages/chat1.php', {
method: 'post',
requestTimeout: 5,
parameters: { text: text, name: name },
evalScripts: true
});
}
var t = false;
t = window.setTimeout('minichat()', 5000000000);
</script>
Maar nog steeds geeft ie de user niet mee.
Wel de chattext.
Dus de error is dan van php
Notice undefined index login
Laat maar opgelost had in PHP nog staan
$login = $_POST['login'];
Dit moetst
$user = $_POST['name']; worden
Bedankt
Gewijzigd op 03/01/2011 21:42:35 door thomas de vries
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
<script type="text/javascript">
function minichat(text,name) {
window.clearTimeout(t);
new Ajax.Updater('chatwindow', '/pages/chat1.php', {
method: 'post',
requestTimeout: 5,
parameters: { text: text, login: name },
evalScripts: true
});
}
var t = false;
t = window.setTimeout('minichat()', 5000000000);
</script>
function minichat(text,name) {
window.clearTimeout(t);
new Ajax.Updater('chatwindow', '/pages/chat1.php', {
method: 'post',
requestTimeout: 5,
parameters: { text: text, login: name },
evalScripts: true
});
}
var t = false;
t = window.setTimeout('minichat()', 5000000000);
</script>
Heel erg bedankt voor het meehelpen. was echt ten einde raad.
Graag gedaan hoor! En een frisse blik helpt altijd!