Array to string conversion
Hallo ik krijg de volgende foutmelding:
mysqli_result Object ( [current_field] => 0 [field_count] => 3 [lengths] => [num_rows] => 1 [type] => 0 )
Notice: Array to string conversion in C:\USB WebServer\root\Youtube18\view.php on line 16
Iemand een idee?
mysqli_result Object ( [current_field] => 0 [field_count] => 3 [lengths] => [num_rows] => 1 [type] => 0 )
Notice: Array to string conversion in C:\USB WebServer\root\Youtube18\view.php on line 16
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
<html>
<body>
<a href ="index.php"></a>
<?php
require_once "connection.php";
$sql = "SELECT * FROM imageupload ORDER BY id DESC";
$res = mysqli_query($conn, $sql);
print_r ($res);
if(mysqli_num_rows($res)> 0)
{
while($images = mysqli_fetch_assoc($res))
{
echo $images;
?>
<div class = "alb">
<img src = "images/<?$images?>">
</div>
<?php }
}
?>
</body>
<html>
<body>
<a href ="index.php"></a>
<?php
require_once "connection.php";
$sql = "SELECT * FROM imageupload ORDER BY id DESC";
$res = mysqli_query($conn, $sql);
print_r ($res);
if(mysqli_num_rows($res)> 0)
{
while($images = mysqli_fetch_assoc($res))
{
echo $images;
?>
<div class = "alb">
<img src = "images/<?$images?>">
</div>
<?php }
}
?>
</body>
<html>
Iemand een idee?
Ja, het veld erbij benoemen als index van je array $images.
Het werkt maar krijg nog geen plaatje te zien.
Wat ontbreekt er nog meer. En ja het plaatje staat in uploads
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
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
<html>
<body>
<a href ="index.php"></a>
<?php
require_once "connection.php";
$sql = "SELECT * FROM imageupload ORDER BY id DESC";
$res = mysqli_query($conn, $sql);
//print_r ($res);
if(mysqli_num_rows($res)> 0)
{
while($images = mysqli_fetch_assoc($res))
{
// print_r ($images);
?>
<div class = "alb">
<img src = "images/<?$images['image']?>">
</div>
<?php }
}
?>
</body>
<html>
<body>
<a href ="index.php"></a>
<?php
require_once "connection.php";
$sql = "SELECT * FROM imageupload ORDER BY id DESC";
$res = mysqli_query($conn, $sql);
//print_r ($res);
if(mysqli_num_rows($res)> 0)
{
while($images = mysqli_fetch_assoc($res))
{
// print_r ($images);
?>
<div class = "alb">
<img src = "images/<?$images['image']?>">
</div>
<?php }
}
?>
</body>
<html>
Wat ontbreekt er nog meer. En ja het plaatje staat in uploads
Probeer eens
je wilt de bestandsnaam wel zichtbaar maken.
je wilt de bestandsnaam wel zichtbaar maken.
Gewijzigd op 01/06/2022 21:35:30 door - Ariën -
de code
Ik krijg de naam van het betand wek te zien maar niet het plaatjes zelf.
het plaatje wat ik zie:
https://ibb.co/pLjyXWc
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
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
<html>
<body>
<a href ="index.php"></a>
<?php
require_once "connection.php";
$sql = "SELECT * FROM imageupload ORDER BY id DESC";
$res = mysqli_query($conn, $sql);
//print_r ($res);
if(mysqli_num_rows($res)> 0)
{
while($images = mysqli_fetch_assoc($res))
{
// print_r ($images);
?>
<div class = "alb">
<img src = "images/<?$images['image']?>">
<?=$images['image'];?>
</div>
<?php }
}
?>
</body>
<html>
<body>
<a href ="index.php"></a>
<?php
require_once "connection.php";
$sql = "SELECT * FROM imageupload ORDER BY id DESC";
$res = mysqli_query($conn, $sql);
//print_r ($res);
if(mysqli_num_rows($res)> 0)
{
while($images = mysqli_fetch_assoc($res))
{
// print_r ($images);
?>
<div class = "alb">
<img src = "images/<?$images['image']?>">
<?=$images['image'];?>
</div>
<?php }
}
?>
</body>
<html>
Ik krijg de naam van het betand wek te zien maar niet het plaatjes zelf.
het plaatje wat ik zie:
https://ibb.co/pLjyXWc
Ik zou je HTML-source in je browser eens checken. Altijd handig in zulke gevallen.
Dan zie je vast wel wat er fout gaat.
Dan zie je vast wel wat er fout gaat.
Lukt het zo?
Ik neem aan dat je onder de afbeelding de titel wil zien.
Code (php)
Ik neem aan dat je onder de afbeelding de titel wil zien.
IK was toch te snel. On het begin werkte het wel. Echter nu ik de echte png 's wil uploaden krijg ik die niet in beeld.
HDM_User2.php
index.php
<!DOCTYPE html>
<html>
<head>
<title>File Upload</title>
</head>
<body>
<form method="post" enctype="multipart/form-data">
<label>Titel</label>
<input type="text" name="title">
<label>File Upload</label>
<input type="File" name="file">
<input type="submit" name="submit">
</form>
</body>
</html>
<?php
//verbinding maken met de database
//$conn = mysqli_connect('localhost', 'root', 'usbw', 'imageupload');// de laatste is de naam van de dadatabase
require_once "connection.php";
if (isset($_POST["submit"]))
{
//file title
$title = $_POST["title"];
//file name
$name = $_FILES["file"]["name"];
//temporary file name to store file
$tname = $_FILES["file"]["tmp_name"];
//upload directory pad
$uploads_dir = 'images';
//Kopieer de dabestanden
move_uploaded_file($tname, $uploads_dir.'/'.$name);
//SQL om de de documenten in de db te zetten
$sql = "INSERT INTO imageupload(title, image) VALUES('$title','$name')";
//echo $sql;
if(mysqli_query($conn, $sql))
{
echo "File Sucessfully uploaded";
}
else{
echo "Error";
}
}
?>
Daarnaast nog 2 plaatjes:
https://ibb.co/bbKNYRw
https://ibb.co/mh9sQS7
Wie kan me helpen?
HDM_User2.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();
if(isset($_SESSION['username']))
{
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="../sidebar3.css">
<link rel="icon" href="../../../../favicon.ico" type="image/x-icon"/>
<title>Helpdeskmedewerker</title>
</head>
<body>
<body>
<div id="container">
<div id="sidebar">
<ul>
<li><a href= "../userhome.php">Home</a></li>
<li><a href= "HDM_User2.php">Groepsdynamica</a></li>
</ul>
<div id="sidebar-content" style="height: 50px"></div>
</div><!--
--><div id="content">
<br>
<!DOCTYPE html>
<html>
<body>
<a href ="index.php"></a>
<?php
require_once "connection.php";
$sql = "SELECT * FROM imageupload ORDER BY id ASC";
$res = mysqli_query($conn, $sql);
//print_r ($res);
if(mysqli_num_rows($res)> 0)
{
while($images = mysqli_fetch_assoc($res))
{
//print_r ($images);
?>
<div class = "alb">
<img src = "images/<?php echo $images['image']; ?>"><!--Plaatje-->
<?php echo $images['title']; ?><!--Titel-->
</div>
<?php }
}
?>
</body>
<html>
<br>
session_start();
if(isset($_SESSION['username']))
{
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="../sidebar3.css">
<link rel="icon" href="../../../../favicon.ico" type="image/x-icon"/>
<title>Helpdeskmedewerker</title>
</head>
<body>
<body>
<div id="container">
<div id="sidebar">
<ul>
<li><a href= "../userhome.php">Home</a></li>
<li><a href= "HDM_User2.php">Groepsdynamica</a></li>
</ul>
<div id="sidebar-content" style="height: 50px"></div>
</div><!--
--><div id="content">
<br>
<!DOCTYPE html>
<html>
<body>
<a href ="index.php"></a>
<?php
require_once "connection.php";
$sql = "SELECT * FROM imageupload ORDER BY id ASC";
$res = mysqli_query($conn, $sql);
//print_r ($res);
if(mysqli_num_rows($res)> 0)
{
while($images = mysqli_fetch_assoc($res))
{
//print_r ($images);
?>
<div class = "alb">
<img src = "images/<?php echo $images['image']; ?>"><!--Plaatje-->
<?php echo $images['title']; ?><!--Titel-->
</div>
<?php }
}
?>
</body>
<html>
<br>
index.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
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
<!DOCTYPE html>
<html>
<head>
<title>File Upload</title>
</head>
<body>
<form method="post" enctype="multipart/form-data">
<label>Titel</label>
<input type="text" name="title">
<label>File Upload</label>
<input type="File" name="file">
<input type="submit" name="submit">
</form>
</body>
</html>
<?php
//verbinding maken met de database
//$conn = mysqli_connect('localhost', 'root', 'usbw', 'imageupload');// de laatste is de naam van de dadatabase
require_once "connection.php";
if (isset($_POST["submit"]))
{
//file title
$title = $_POST["title"];
//file name
$name = $_FILES["file"]["name"];
//temporary file name to store file
$tname = $_FILES["file"]["tmp_name"];
//upload directory pad
$uploads_dir = 'images';
//Kopieer de dabestanden
move_uploaded_file($tname, $uploads_dir.'/'.$name);
//SQL om de de documenten in de db te zetten
$sql = "INSERT INTO imageupload(title, image) VALUES('$title','$name')";
//echo $sql;
if(mysqli_query($conn, $sql))
{
echo "File Sucessfully uploaded";
}
else{
echo "Error";
}
}
?>
Daarnaast nog 2 plaatjes:
https://ibb.co/bbKNYRw
https://ibb.co/mh9sQS7
Wie kan me helpen?
Gewijzigd op 07/06/2022 23:06:13 door - Ariën -
Check je HTML-source en oordeel dan eens verder... ;-)
- Klopt het pad wel?
- Heb je al in de Debugging-tool van je browser gekeken waar die de afbeeldingen ophaalt?

Debugging-tool is altijd een aanrader. ken je het niet, leer dan hoe het werkt.
Het is altijd de redder in nood.
- Klopt het pad wel?
- Heb je al in de Debugging-tool van je browser gekeken waar die de afbeeldingen ophaalt?

Debugging-tool is altijd een aanrader. ken je het niet, leer dan hoe het werkt.
Het is altijd de redder in nood.
Gewijzigd op 07/06/2022 23:15:45 door - Ariën -
Hoi,
Ik heb het allemaal werkend gekregen. Vervolgens een dikken 300 en 500 bladzijdes er in krijgen is natuurlijk monnikenwerk. Ik heb dus Libre Calc gebruikt (of misbruikt!)
PLaatje
https://ibb.co/Lppwmyf
Groetjes
Ed
Ik heb het allemaal werkend gekregen. Vervolgens een dikken 300 en 500 bladzijdes er in krijgen is natuurlijk monnikenwerk. Ik heb dus Libre Calc gebruikt (of misbruikt!)
PLaatje
https://ibb.co/Lppwmyf
Groetjes
Ed



