php error Uncaught exception

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Wesley Overdijk

wesley Overdijk

05/12/2009 13:48:00
Quote Anchor link
Beste,

Ik ben net nieuw in het hele try catch gebeuren.. Nu krijg ik een error waar ik niet helemaal uitkom. kan iemand mij helpen?

Code:
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
<?php
public function checkThread($messId, $userID, $recID)
        {

            $checkThreadValid = "select * from strtmessages where uid=$userID and recid=$recID and id=$messId or uid=$recID and recid=$userID and id=$messId";
            try
            {
                if(mysql_query($checkThreadValid))
                {

                    if(mysql_num_rows($checkThreadValid) > 0)
                    {

                        return true;  
                    }

                    else
                    {
                        throw new Exception('Something went wrong. Users didn\'t match in class_message at ± 14.');  
                    }
                }

                else
                {
                    throw new Exception('SQL error while checking thread: '.mysql_error());
                }    
            }

            catch(Exeption $returnedError)
            {

                   if(settings::debugging)
                    {

                        echo $returnedError->getMessage();
                    }

                    else
                    {
                        return false;  
                    }          
            }                
        }

?>


error:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Users\solow\Desktop\UsbWebserver\Root\projects\messaging\modules\class_message.php on line 18

Fatal error: Uncaught exception 'Exception' with message 'Something went
 wrong. Users didn't match in class_message at  14.' in C:\Users\solow
\Desktop\UsbWebserver\Root\projects\messaging\modules
\class_message.php:24 Stack trace: #0 C:\Users\solow\Desktop
\UsbWebserver\Root\projects\messaging\modules\class_message.php(90):
 message->checkThread(19, '2', '1') #1 C:\Users\solow\Desktop\UsbWebserver
\Root\projects\messaging\index.php(6): message->send('2', '1', 'dit is een
 repl...', false, 19) #2 {main} thrown in C:\Users\solow\Desktop\UsbWebserve
r\Root\projects\messaging\modules\class_message.php on line 24



Alvast bedankt.
Gewijzigd op 01/01/1970 01:00:00 door Wesley Overdijk
 
PHP hulp

PHP hulp

21/11/2024 19:21:29
 
Wesley Overdijk

wesley Overdijk

05/12/2009 13:54:00
Quote Anchor link
lol. stomme fout. 'Exeption' ipv Exception

sorry.
 
Maestro Roboroads

Maestro Roboroads

05/12/2009 14:49:00
Quote Anchor link
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
<?php
public function checkThread($messId, $userID, $recID)
        {

            $checkThreadValid = "select * from strtmessages where uid=$userID and recid=$recID and id=$messId or uid=$recID and recid=$userID and id=$messId";
            try
            {
                if(mysql_query($checkThreadValid))
                {

                    if(mysql_num_rows($checkThreadValid) > 0)
                    {

                        return true;  
                    }

                    else
                    {
                        throw new Exception('Something went wrong. Users didn\'t match in class_message at ± 14.');  
                    }
                }

                else
                {
                    throw new Exception('SQL error while checking thread: '.mysql_error());
                }    
            }

            catch(Exception $returnedError)
            {

                   if(settings::debugging)
                    {

                        echo $returnedError->getMessage();
                    }

                    else
                    {
                        return false;  
                    }          
            }                
        }

?>


Zo dan maar?
Gewijzigd op 01/01/1970 01:00:00 door Maestro Roboroads
 

05/12/2009 14:57:00
Quote Anchor link
roboroads schreef op 05.12.2009 14:49:
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
<?php
public function checkThread($messId, $userID, $recID)
        {

            $checkThreadValid = "select * from strtmessages where uid=$userID and recid=$recID and id=$messId or uid=$recID and recid=$userID and id=$messId";
            try
            {
                if(mysql_query($checkThreadValid))
                {

                    if(mysql_num_rows($checkThreadValid) > 0)
                    {

                        return true;  
                    }

                    else
                    {
                        throw new Exeption('Something went wrong. Users didn\'t match in class_message at ± 14.');  
                    }
                }

                else
                {
                    throw new Exeption('SQL error while checking thread: '.mysql_error());
                }    
            }

            catch(Exeption $returnedError)
            {

                   if(settings::debugging)
                    {

                        echo $returnedError->getMessage();
                    }

                    else
                    {
                        return false;  
                    }          
            }                
        }

?>


Zo dan maar?

OMFG je doet het precies verkeerd om.
Ga jij even lekker sql leren ofzo en niet bezig houden met OOP.
En ook lezen wat hij zegt. Hij zegt dat hij Exeption deed in plaats van Exception.
In de catch was het dus fout.
Niet in de throw.
 
Wesley Overdijk

wesley Overdijk

05/12/2009 16:32:00
Quote Anchor link
LOL. Geen commentaar. Toch bedankt voor de poging. :)
 



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.