mysqli probleem na include tweede pagina

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Senior, Medior and Junior SAP HANA Developer

Vacature details Vakgebied: Software/IT Opleiding: Medior Werklocatie: Veldhoven Vacature ID: 12696 Introductie Our client is the world's leading provider of lithography systems for the semiconductor industry, manufacturing complex machines that are critical to the production of integrated circuits or chips. Our purpose is “unlocking the potential of people and society by pushing technology to new limits”. We do this guided by the principles “Challenge”, “Collaborate” and “Care”. Wat verwachten we van jou? SAP Certified Application Associate - SAP HANA Cloud Modeling (training and/or certification) Bachelor degree or higher Excellent understanding of SAP HANA (2.0 / Cloud), Data Modelling and writing

Bekijk vacature »

Twan T

Twan T

15/06/2011 14:45:12
Quote Anchor link
Ik bouw mijn pagina op door twee tabellen te vullen,
links menu (database info) rechts pagina info ook database info.

Nu gebruik ik in beide mysqli query's maar krijg ik bij het laden van het rechter deel foutmeldingen.

Open ik de info pagina los dan gaat dit wel goed, ik ben er al achter dat als ik als query veriabelen q1,q2,q3 gebruik dat het goed gaat maar gebruik ik twee keer q1 dan krijg ik fouten.

Het zal wel te maken hebben met het vrijmaken van de variabelen maar ik kan het probleem zelf niet achterhalen.

index.php

include main.php
include menu.php

menu
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<?php
        
//
        
$q1 = "SELECT * FROM menu_cat ORDER BY niveau";    // q1 = Query 1
$r1 = @mysqli_query ($dbc, $q1);                          // Run the query geeft result 1 (r1)

// Count the number of returned rows:

$num1 = mysqli_num_rows($r1);
      
if($num1>0) {//If it run OK display records.
    
while ($row1 = mysqli_fetch_array($r1, MYSQLI_ASSOC)) {
    
    echo $row1['name'] . '<br />';
    
    $id = $row1['id'];
        
    echo $menu_cat;
    
    //  Count menu_items for every menu_cat
    $q2 = "SELECT * FROM menu_item WHERE menu_item.menu_cat_id = '$row1[id]'";                    
    $r2 = @mysqli_query ($dbc, $q2);                         
    $menu_item = mysqli_num_rows($r2);
        
    
    $num2 = mysqli_num_rows($r2);
      
    if($num2>0) {//If it run OK display records.
    
        while ($row2 = mysqli_fetch_array($r2, MYSQLI_ASSOC)) {
                                
        echo  '<a href="' . $row2['url'] . '">' . $row2['name'] . '</a><br />';
            
        // <a href="Toevoegen.php">Toevoegen</a>
    
    }
        
    }
else {
        echo '';
    }

        
    }
        
    }
else { // If no records were returned.
        
        echo 'No records';
    }


    mysqli_close($dbc);


?>


main.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
<?php
    require_once ('./mysqli_connect.php');

    $q1 = "SELECT * FROM klanten_info";                    
    $r1 = @mysqli_query ($dbc, $q1);                         
    $menu_item = mysqli_num_rows($r1);
    
?>
Gewijzigd op 15/06/2011 16:39:09 door Twan T
 
PHP hulp

PHP hulp

28/03/2024 14:44:17
 
- SanThe -

- SanThe -

15/06/2011 14:55:03
Quote Anchor link
Gebruik de [ en ] bij de code tags en niet < en >.
 
John Cena

John Cena

15/06/2011 16:08:05
Quote Anchor link
Relevante code is genoeg, hoef geen table, tr etc bulshit te zien.
 
Pieter van Linschoten

Pieter van Linschoten

15/06/2011 16:12:05
Quote Anchor link
Om sneller de aard van het probleem te kunnen vinden (ook handig in de toekomst) is het raadzaam een goede foutafhandeling op te nemen in je programmeerwerkzaamheden.

Hoe je dat voorelkaar krijgt.
http://www.phphulp.nl/php/tutorial/data-verwerking/foutafhandeling-in-php-error-handling/571/

Verder zorgt @mysql_query ervoor dat eventuele fouten in je Query worden onderdrukt, en je dus geen idee hebt, wat er mis gaat.

Ten slotte:

Welke foutmelding krijg je?
 
Twan T

Twan T

15/06/2011 16:40:22
Quote Anchor link
De foutmelding =

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /customers/xxx.com/xxx.com/httpd.www/xxx/klanten_stats.php on line 6 Klanten overzicht::
Totaal aantal klanten:
Laatst toegevoegde klant:
Laatst gewijzigde klant:
Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, null given in /customers/xxx.com/xxx.com/httpd.www/xxx/klanten_stats.php on line 29 Warning: mysqli_close(): Couldn't fetch mysqli in /customers/xxx.com/xxx.com/httpd.www/xxx/klanten_stats.php on line 30
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.