Catchable fatal error: Object of class mysqli could not be converted to string
Louis Deconinck
18/05/2014 13:51:12Ik krijg deze error: Catchable fatal error: Object of class mysqli could not be converted to string in public_html/index.php on line 17
Wat doe ik verkeerd en hoe kan ik het probleem oplossen?
Wat doe ik verkeerd en hoe kan ik het probleem oplossen?
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
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
<?php
ini_set('display_errors', 1); // 0 = uit, 1 = aan
error_reporting(E_ALL);
$link=mysqli_connect("*****","****","*****","*****");
$result1 = mysqli_query($link, "SELECT * FROM main");
$num_rows = mysqli_num_rows($result1);
$person1=rand(1, $num_rows);
$person2=rand(1, $num_rows);
while ($person2 == $person1) {
$person2=rand(1, $num_rows);
}
$result2 = mysqli_query("$link, SELECT * FROM main WHERE id=$person1");
$row1 = mysqli_fetch_row($result2);
$fbid1=$row1['fbid'];
$result3 = mysqli_query("$link, SELECT * FROM main WHERE id=$person2");
$row2 = mysqli_fetch_row($result3);
$fbid2=$row2['fbid'];
echo "$fbid1 en $fbid2";
?>
ini_set('display_errors', 1); // 0 = uit, 1 = aan
error_reporting(E_ALL);
$link=mysqli_connect("*****","****","*****","*****");
$result1 = mysqli_query($link, "SELECT * FROM main");
$num_rows = mysqli_num_rows($result1);
$person1=rand(1, $num_rows);
$person2=rand(1, $num_rows);
while ($person2 == $person1) {
$person2=rand(1, $num_rows);
}
$result2 = mysqli_query("$link, SELECT * FROM main WHERE id=$person1");
$row1 = mysqli_fetch_row($result2);
$fbid1=$row1['fbid'];
$result3 = mysqli_query("$link, SELECT * FROM main WHERE id=$person2");
$row2 = mysqli_fetch_row($result3);
$fbid2=$row2['fbid'];
echo "$fbid1 en $fbid2";
?>
PHP hulp
22/11/2024 04:12:23Erwin H
18/05/2014 14:25:16Kijk gewoon eens naar die regel 17:
Code (php)
1
2
3
4
5
6
7
2
3
4
5
6
7
<?php
//niet zo:
$result2 = mysqli_query("$link, SELECT * FROM main WHERE id=$person1");
//maar zo:
$result2 = mysqli_query($link, "SELECT * FROM main WHERE id=$person1");
?>
//niet zo:
$result2 = mysqli_query("$link, SELECT * FROM main WHERE id=$person1");
//maar zo:
$result2 = mysqli_query($link, "SELECT * FROM main WHERE id=$person1");
?>
Gewijzigd op 18/05/2014 14:25:36 door Erwin H