[PHP/MYSQL]Kan de laatste stuk niet ophalen

Pagina: 1
Acties:
  • 77 views sinds 30-01-2008

  • amiga1260
  • Registratie: Juni 2003
  • Laatst online: 25-05 17:01
Ik kan de laatste stuk van het tabel niet ophalen met PHP. De gegevens staan er wel in, maar ik krijg ze niet eruit.

Hier is mijn Tabel in MySQL:

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
CREATE TABLE `Invulveld` (
  `Invulveld_ID` int(11) NOT NULL auto_increment,
  `Invulveld_naam` varchar(25) NOT NULL default '',
  `Invulveld_lengte` int(11) NOT NULL default '0',
  `Invulveld_maxlengte` int(11) NOT NULL default '0',
  `Invulveld_type` varchar(10) NOT NULL default '',
  `Invulveld_soort` varchar(10) NOT NULL default '',
  `Invulveld_afkorting` varchar(10) NOT NULL default '',
  `Invulveld_verplicht` char(3) NOT NULL default '',
  PRIMARY KEY  (`Invulveld_ID`)
) TYPE=MyISAM;


#
# Dumping data for table Invulveld
#

INSERT INTO `Invulveld` VALUES (1,'Achternaam',20,20,'text','persoon','Achter','ja');


Met de volgende code haal ik het op:

code:
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
<?php
{
    $host = "test";
    $login_name = "amo";
    $password = "amo";
    MySQL_connect("$host","$login_name","$password");
    MySQL_select_db("test") or die("Kan de database niet selecteren");

$query = "SELECT * FROM Invulveld where Invulveld_ID='1'";
    $result = MySQL_query($query);
    While( $rows = MySQL_fetch_array($result) )
    {
        $Invulveld_ID = $rows['Invulveld_ID'];
        $Invulveld_naam = $rows['Invulveld_naam'];
        $Invulveld_lengte = $rows['Invulveld_lengte'];
        $Invulveld_maxlengte = $rows['Invulveld_maxlengte'];
        $Invulveld_type = $rows['Invulveld_type'];
        $invulveldsoort = $row['Invulveld_soort'];
        $Invulveld_afkorting = $row['Invulveld_afkorting'];
        $Invulveld_verplicht = $row['Invulveld_verplicht'];
        echo("$Invulveld_ID<br>"); 
        echo("$Invulveld_naam<br>"); 
        echo("$Invulveld_lengte<br>"); 
        echo("$Invulveld_maxlengte<br>"); 
        echo("$Invulveld_type<br>"); 
        echo("$invulveld_soort<br>"); 
        echo("$invulveld_afkorting<br>"); 
        echo("$invulveld_verplicht<br>");
        }
        MySQL_close();
}
?>


Als output krijg ik dit:

1
Achternaam
20
20
text

Wat heb ik dan verkeerd gedaan?

[ Voor 17% gewijzigd door amiga1260 op 22-04-2004 13:06 . Reden: Code van PHP aangepast ]


  • Janoz
  • Registratie: Oktober 2000
  • Laatst online: 00:01

Janoz

Moderator Devschuur®

!litemod

De verkeerde kolomnamen gebruikt.

Ken Thompson's famous line from V6 UNIX is equaly applicable to this post:
'You are not expected to understand this'


  • Brakkie
  • Registratie: Maart 2001
  • Niet online

Brakkie

blaat

print(mysql_error());

Biedt vaak uitkomst.
Waarom gebruik je trouwens een while loop als je toch maar 1 rij ophaalt.
edit:

Maar in dit geval dus niet. zie ^^

[ Voor 68% gewijzigd door Brakkie op 22-04-2004 12:49 ]

Systeem | Strava


  • amiga1260
  • Registratie: Juni 2003
  • Laatst online: 25-05 17:01
De While loop gebruik om meerder gegevens op te halen.

  • amiga1260
  • Registratie: Juni 2003
  • Laatst online: 25-05 17:01
Ik heb print(mysql_error()); gebruikt, maar ik krijg geen foutmelding.

  • Markieman
  • Registratie: December 2001
  • Laatst online: 15-05 12:16
Probeer het eens zo:


code:
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
<?php
{
    $host = "test";
    $login_name = "amo";
    $password = "amo";
    MySQL_connect("$host","$login_name","$password");
    MySQL_select_db("test") or die("Kan de database niet selecteren");

$query = "SELECT * FROM Invulveld where Invulveld_ID='1'";
    $result = MySQL_query($query);
    While( $rows = MySQL_fetch_array($result) )
    {
        $Invulveld_ID = $rows['Invulveld_ID'];
        $Invulveld_naam = $rows['Invulveld_naam'];
        $Invulveld_lengte = $rows['Invulveld_lengte'];
        $Invulveld_maxlengte = $rows['Invulveld_maxlengte'];
        $Invulveld_type = $rows['Invulveld_type'];
        $Invulveld_soort = $row['Invulveld_soort'];
        $Invulveld_afkorting = $row['Invulveld_afkorting'];
        $Invulveld_verplicht = $row['Invulveld_verplicht'];
        echo("$Invulveld_ID<br>"); 
        echo("$Invulveld_naam<br>"); 
        echo("$Invulveld_lengte<br>"); 
        echo("$Invulveld_maxlengte<br>"); 
        echo("$Invulveld_type<br>"); 
        echo("$Invulveld_soort<br>"); 
        echo("$Invulveld_afkorting<br>"); 
        echo("$Invulveld_verplicht<br>");
        }
        MySQL_close();
}
?>


btw:
het is niet: "Kan de laatste stuk niet ophalen"
maar: "Kan het laatste stuk niet ophalen"

[ Voor 41% gewijzigd door Markieman op 22-04-2004 14:11 ]

You do not fear them? - The Wraith? Naah. Now *clowns*, that's another story.


  • cameodski
  • Registratie: Augustus 2002
  • Laatst online: 06-11-2023
Kun je in je query alle kolomnamen die je wilt hebben eens noemen ipv select * te gebruiken.
Misschien dat ie toch op één of andere manier de kolommen die je wilt hebben niet kan vinden.

Never underestimate the power of


Verwijderd

volgens mij is de enige fout het feit dat je hoofdletters en kleine letters door mekaar gebruikt:
de ene keer schrijf je $Invulveld, de andere keer $invulveld...

  • Markieman
  • Registratie: December 2001
  • Laatst online: 15-05 12:16
Verwijderd schreef op 22 april 2004 @ 14:27:
volgens mij is de enige fout het feit dat je hoofdletters en kleine letters door mekaar gebruikt:
de ene keer schrijf je $Invulveld, de andere keer $invulveld...
En hij was een underscore vergeten bij $Invulveldsoort ipv $Invulveld_soort

(zie ook mijn vorige post)

You do not fear them? - The Wraith? Naah. Now *clowns*, that's another story.


  • Janoz
  • Registratie: Oktober 2000
  • Laatst online: 00:01

Janoz

Moderator Devschuur®

!litemod

Maar goed.. Simpel debug probleempje dus. Het lijkt me nu iig wel duidelijk......

Ken Thompson's famous line from V6 UNIX is equaly applicable to this post:
'You are not expected to understand this'

Pagina: 1

Dit topic is gesloten.