mysql error maar hij voert mijn opdracht toch uit
Misschien is deze script verouderd, maar ik als beginneling, probeer'm aan de praat te krijgen.
Hij doet het wel en voert mijn opdracht uit, maar waarom krijg ik deze foutmelding?
mysql_result(): Unable to jump to row 0 on MySQL result index 5 in /home/httpd/vhosts/tralala.com/httpdocs/tralala/beheer/header.php on line 323
Op line 323 staat:
echo "Item: <b>" . mysql_result ($query, 0)."</b>";
Is hier misschien een betere code voor?
Ik hoor het graag, Bedankt
laat je verdere SQL codes eens zien, dus de SQL code en daarna de functie mysql_query(), (of je hebt ze samengevoegd)..
want alleen hier kan ik niet zoveel mee..
Hieronder de complete header (het is een sript uit 2002)
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
129
130
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
129
130
<?
include "../db.php";
function dyn($url){
$dhtml = "onclick=\"javascript:document.location='".$url."'\" style=\"CURSOR: hand\" ";
echo $dhtml;
}
if ($cmd == "update"){
$inhoud = addslashes(htmlspecialchars($inhoud));
$pieces = explode("+|+",$field_arr);
for ($i = 0; $i < count($pieces); $i++){
$tmp_piece = "$".$pieces[$i];
eval("\$tmp_piece = \"$tmp_piece\";");
$pieces2[$i] = $tmp_piece;
}
for ($i = 0; $i < count($pieces); $i++){
$sql = $sql.$pieces[$i]."='".$pieces2[$i]."', ";
}
$sql = substr($sql, 0, -2);
echo "update $table set $sql where id='$vacid'";
mysql_query("update $table set $sql where id='$vacid'");
$cmd = "vacatures";
}
if ($cmd == "addrecord"){
$inhoud = addslashes(htmlspecialchars($inhoud));
$pieces = explode("+|+",$field_arr);
for ($i = 0; $i < count($pieces); $i++){
$tmp_piece = "$".$pieces[$i];
eval("\$tmp_piece = \"$tmp_piece\";");
$pieces[$i] = $tmp_piece;
}
for ($i = 0; $i < count($pieces); $i++){
$sql = $sql."'".$pieces[$i]."', ";
}
$sql = substr($sql, 0, -2);
// echo "insert into $table values ($sql)";
mysql_query("insert into $table values ($sql)") or die ("nee");
$cmd = "vacatures";
}
if ($cmd == "savenew" && $insert == false){
mysql_query("insert into functies values ('', '$inhoud', '$catid')");
$cmd = "";
}
if ($cmd == "saveedit"){
mysql_query("update functies set functienaam='$inhoud' where functieid='$item'");
$cmd = "";
}
if ($cmd == "del"){
mysql_query ("delete from functies where functieid='$item'");
$cmd = "";
}
if ($cmd2 == "delvac"){
mysql_query ("delete from vacatures where id='$item'");
$cmd = "vacatures";
}
if ($cmd == "del2"){
mysql_query ("delete from cv where cvid='$item'");
$cmd = "zoeken";
}
?>
include "../db.php";
function dyn($url){
$dhtml = "onclick=\"javascript:document.location='".$url."'\" style=\"CURSOR: hand\" ";
echo $dhtml;
}
if ($cmd == "update"){
$inhoud = addslashes(htmlspecialchars($inhoud));
$pieces = explode("+|+",$field_arr);
for ($i = 0; $i < count($pieces); $i++){
$tmp_piece = "$".$pieces[$i];
eval("\$tmp_piece = \"$tmp_piece\";");
$pieces2[$i] = $tmp_piece;
}
for ($i = 0; $i < count($pieces); $i++){
$sql = $sql.$pieces[$i]."='".$pieces2[$i]."', ";
}
$sql = substr($sql, 0, -2);
echo "update $table set $sql where id='$vacid'";
mysql_query("update $table set $sql where id='$vacid'");
$cmd = "vacatures";
}
if ($cmd == "addrecord"){
$inhoud = addslashes(htmlspecialchars($inhoud));
$pieces = explode("+|+",$field_arr);
for ($i = 0; $i < count($pieces); $i++){
$tmp_piece = "$".$pieces[$i];
eval("\$tmp_piece = \"$tmp_piece\";");
$pieces[$i] = $tmp_piece;
}
for ($i = 0; $i < count($pieces); $i++){
$sql = $sql."'".$pieces[$i]."', ";
}
$sql = substr($sql, 0, -2);
// echo "insert into $table values ($sql)";
mysql_query("insert into $table values ($sql)") or die ("nee");
$cmd = "vacatures";
}
if ($cmd == "savenew" && $insert == false){
mysql_query("insert into functies values ('', '$inhoud', '$catid')");
$cmd = "";
}
if ($cmd == "saveedit"){
mysql_query("update functies set functienaam='$inhoud' where functieid='$item'");
$cmd = "";
}
if ($cmd == "del"){
mysql_query ("delete from functies where functieid='$item'");
$cmd = "";
}
if ($cmd2 == "delvac"){
mysql_query ("delete from vacatures where id='$item'");
$cmd = "vacatures";
}
if ($cmd == "del2"){
mysql_query ("delete from cv where cvid='$item'");
$cmd = "zoeken";
}
?>
<html>
<table width="600" border="0" cellspacing="1" cellpadding="1">
<tr>
<td valign=bottom align="left">
[<a href="">Zoek CV</a>]
[<a href="">Verzonden CV's</a>]
[<a href="">Opleiding</a>]
[<a href="">Werkervaring</a>]
[<a href="">Regio</a>]
[<a href="">Functie</a>]
[<a href="">Functie(eng)</a>]
[<a href="">vacatures</a>]
[<a href="javascript:window.close()">Logout</a>]
</td>
</tr>
</table>
<br>
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
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
<?
if ( empty($catid)){
if ( empty($cmd)){
$cmd = "zoeken";
}
}
if ( $cmd != "zoeken"
and $cmd != "sended"
and $cmd != "viewitem"
and $cmd != "vacatures"
and $cmd != "viewvac"
and $cmd != "sendcv"
and $cmd != "sendcv2"
and $cmd != "editvac"
and $cmd != "addvac"){
$query = mysql_query("select catnaam from cat where catid='$catid'");
echo "Item: <b>" . mysql_result ($query, 0)."</b>";
}
?>
if ( empty($catid)){
if ( empty($cmd)){
$cmd = "zoeken";
}
}
if ( $cmd != "zoeken"
and $cmd != "sended"
and $cmd != "viewitem"
and $cmd != "vacatures"
and $cmd != "viewvac"
and $cmd != "sendcv"
and $cmd != "sendcv2"
and $cmd != "editvac"
and $cmd != "addvac"){
$query = mysql_query("select catnaam from cat where catid='$catid'");
echo "Item: <b>" . mysql_result ($query, 0)."</b>";
}
?>
Quote:
(het is een sript uit 2002)
waar schijnlijk is deze in een andere versie van PHP geschreven en getest
Voor de header.php geen foutmeldingen meer.
Toch bedankt voor de aandacht.
Onderste stukje code vervangen:
Oud
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?
if ($cmd != "zoeken"
and $cmd != "sended"
and $cmd != "viewitem"
and $cmd != "vacatures"
and $cmd != "viewvac"
and $cmd != "sendcv"
and $cmd != "sendcv2"
and $cmd != "editvac"
and $cmd != "addvac"){
$query = @mysql_query("select catnaam from cat where catid='$catid'");
echo "Item: <b>" . @mysql_result ($query, 0)."</b>";
}
?>
if ($cmd != "zoeken"
and $cmd != "sended"
and $cmd != "viewitem"
and $cmd != "vacatures"
and $cmd != "viewvac"
and $cmd != "sendcv"
and $cmd != "sendcv2"
and $cmd != "editvac"
and $cmd != "addvac"){
$query = @mysql_query("select catnaam from cat where catid='$catid'");
echo "Item: <b>" . @mysql_result ($query, 0)."</b>";
}
?>
EINDE OUD
Vervangen door:
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
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
<?
if ( $cmd != "zoeken"
and $cmd != "sended"
and $cmd != "viewitem"
and $cmd != "vacatures"
and $cmd != "viewvac"
and $cmd != "sendcv"
and $cmd != "sendcv2"
and $cmd != "editvac"
and $cmd != "addvac"
)
{
if ($catid !=0)
{
$query = "SELECT catnaam FROM cat WHERE catid=".$catid;
$result = mysql_query($query);
if (mysql_errno()==0)
{
$row = mysql_fetch_assoc($result);
echo "Item: <b>".$row["catnaam"]."</b>";
}
else
{
echo "Item: <b>Kon niet opgehaald worden! [Error #".mysql_errno()." / ".mysql_error()."]</b>";
}
}
else
{
echo "CatID-waarde is 0 !";
}
}
?>
if ( $cmd != "zoeken"
and $cmd != "sended"
and $cmd != "viewitem"
and $cmd != "vacatures"
and $cmd != "viewvac"
and $cmd != "sendcv"
and $cmd != "sendcv2"
and $cmd != "editvac"
and $cmd != "addvac"
)
{
if ($catid !=0)
{
$query = "SELECT catnaam FROM cat WHERE catid=".$catid;
$result = mysql_query($query);
if (mysql_errno()==0)
{
$row = mysql_fetch_assoc($result);
echo "Item: <b>".$row["catnaam"]."</b>";
}
else
{
echo "Item: <b>Kon niet opgehaald worden! [Error #".mysql_errno()." / ".mysql_error()."]</b>";
}
}
else
{
echo "CatID-waarde is 0 !";
}
}
?>
Gewijzigd op 19/08/2004 15:03:00 door Raspoetin