Error in PHP

Gestart doorWouterr26 reacties90 weergaven

27 berichten · pagina 1 van 2

Wouterr

Lid · Topicstarter

Berichten
5.274
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien

Eindhoven, Nederland

Hoi one2xs,

Ik heb ben bezig met een script maar ik loop tegen een error aan:

Code:

[COLOR= #0000BB]<?[/COLOR]
    [URL="http://www.php.net/class"]class[/URL] Resp [COLOR= #007700]{
        var[/COLOR] [COLOR= #0000BB]$xmlData[/COLOR][COLOR= #007700];
        
        function[/COLOR] send[COLOR= #007700]() {[/COLOR]
            [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]xmlData [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]</Response>[/COLOR][COLOR= #007700];[/COLOR]
            [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Content-Type: text/xml[/COLOR][COLOR= #007700]);[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]xmlData[COLOR= #007700];
        }
        
        function[/COLOR] init[COLOR= #007700]() {[/COLOR]
            [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]xmlData [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]<?xml version="1.0"?>[/COLOR][COLOR= #007700];[/COLOR]
            [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]xmlData [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]<Response>[/COLOR][COLOR= #007700];
        }
        
        function[/COLOR] addMsg[COLOR= #007700]([/COLOR][COLOR= #0000BB]$msg[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$newnick[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700]) {[/COLOR]
            [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]xmlData [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]<Message[/COLOR][COLOR= #007700].([/COLOR][COLOR= #0000BB]$newnick[/COLOR] [COLOR= #007700]!=[/COLOR] [COLOR= #DD0000][/COLOR] [COLOR= #007700]?[/COLOR] [COLOR= #DD0000] nick="[/COLOR][COLOR= #007700].[/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$newnick[/COLOR][COLOR= #007700],[/COLOR] ENT_QUOTES[COLOR= #007700]).[/COLOR][COLOR= #DD0000]"[/COLOR] [COLOR= #007700]:[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000]>[/COLOR][COLOR= #007700];[/COLOR]
            [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]xmlData [COLOR= #007700].=[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$msg[/COLOR][COLOR= #007700],[/COLOR] ENT_QUOTES[COLOR= #007700]);[/COLOR]
            [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]xmlData [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]</Message>[/COLOR][COLOR= #007700];
        }
        
        function[/COLOR] buzzer[COLOR= #007700]() {[/COLOR]
            [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]xmlData [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]<Buzzer />[/COLOR][COLOR= #007700];
        }
        
        function[/COLOR] newNick[COLOR= #007700]([/COLOR][COLOR= #0000BB]$nick[/COLOR][COLOR= #007700]) {[/COLOR]
            [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]xmlData [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]<Nick>[/COLOR][COLOR= #007700].[/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$nick[/COLOR][COLOR= #007700],[/COLOR] ENT_QUOTES[COLOR= #007700]).[/COLOR][COLOR= #DD0000]</Nick>[/COLOR][COLOR= #007700];
        }

        function[/COLOR] newPSM[COLOR= #007700]([/COLOR][COLOR= #0000BB]$psm[/COLOR][COLOR= #007700]) {[/COLOR]
            [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]xmlData [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]<PSM>[/COLOR][COLOR= #007700].[/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$psm[/COLOR][COLOR= #007700],[/COLOR] ENT_QUOTES[COLOR= #007700]).[/COLOR][COLOR= #DD0000]</PSM>[/COLOR][COLOR= #007700];
        }
        
        function[/COLOR] leave[COLOR= #007700]() {[/COLOR]
            [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]xmlData [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]<Leave />[/COLOR][COLOR= #007700];
        }
    }[/COLOR]

    [COLOR= #FF8000]// Hier de gehele woordenlijst[/COLOR]
    [COLOR= #0000BB]$woorden[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR] [COLOR= #FF8000]// Voeg alle woorden hieronder toe[/COLOR]
[URL="http://www.php.net/require_once"]require_once[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]connect.php[/COLOR][COLOR= #007700]);[/COLOR]
    [COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"
        SELECT woord, antwoord
        FROM msnbot
        "[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$res[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700])) {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]FORUMCODE0[/COLOR][COLOR= #007700];
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
        [COLOR= #0000BB]$tellen[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$res[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$teller[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// teller start met 0[/COLOR]
        [URL="http://www.php.net/while"]while[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$res[/COLOR][COLOR= #007700])) {[/COLOR]
            [COLOR= #0000BB]$teller[/COLOR][COLOR= #007700]++;[/COLOR] [COLOR= #FF8000]// teller eentje verhogen (1ste is dus nummer 1, 2de nnummer 2, etc..)[/COLOR]
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$teller[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]$tellen[/COLOR][COLOR= #007700]){[/COLOR] 
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000].nl2br(stripslashes($row[[/COLOR]woord[COLOR= #DD0000]])). => .nl2br(stripslashes($row[[/COLOR]antwoord[COLOR= #DD0000]])).);[/COLOR][COLOR= #007700];
            }[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000].nl2br(stripslashes($row[[/COLOR]woord[COLOR= #DD0000]])). => .nl2br(stripslashes($row[[/COLOR]antwoord[COLOR= #DD0000]])).,[/COLOR][COLOR= #007700];
            }
        }
    }[/COLOR]
    [COLOR= #0000BB]$anders[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Wij zijn nog bezig met deze BOT![/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Dit wordt gezegd als de bot het niet snapt

    // Het script, hier niets veranderen[/COLOR]
    [COLOR= #0000BB]$resp[/COLOR] [COLOR= #007700]= new[/COLOR] Resp[COLOR= #007700]();[/COLOR]
    [COLOR= #0000BB]$resp[/COLOR][COLOR= #007700]->[/COLOR]init[COLOR= #007700]();[/COLOR]
    [COLOR= #0000BB]$msg[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/str_replace"]str_replace[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]:[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000])[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]([/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000];[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]?[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]![/COLOR][COLOR= #007700]),[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/strip_tags"]strip_tags[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strtolower"]strtolower[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/base64_decode"]base64_decode[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]msg[/COLOR][COLOR= #007700]]))));[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$woorden[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$msg[/COLOR][COLOR= #007700]])) {[/COLOR]
        [COLOR= #0000BB]$resp[/COLOR][COLOR= #007700]->[/COLOR]addMsg[COLOR= #007700]([/COLOR][COLOR= #0000BB]$woorden[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$msg[/COLOR][COLOR= #007700]]);
    }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #0000BB]$resp[/COLOR][COLOR= #007700]->[/COLOR]addMsg[COLOR= #007700]([/COLOR][COLOR= #0000BB]$anders[/COLOR][COLOR= #007700]);[/COLOR]
    [COLOR= #0000BB]$resp[/COLOR][COLOR= #007700]->[/COLOR]send[COLOR= #007700]();[/COLOR]
?>


Fout:

Parse error: syntax error, unexpected ;, expecting ) in /home/snabbonl/domains/snabbo.nl/public_html/msnbot.php on line 41


De database bestaat en het is voor me MSN Bot.

Alvast bedankt biggrinHabboEffect
0
Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Doe dit op regel 41:

require_once connect.php;
0
Wouterr

Lid · Topicstarter

Berichten
5.274
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien

Eindhoven, Nederland

nog steeds deze error:
Parse error: syntax error, unexpected ;, expecting ) in /home/snabbonl/domains/snabbo.nl/public_html/msnbot.php on line 41
0
Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dit op regel 40

$woorden = array // Voeg alle woorden hieronder toe
0
Wouterr

Lid · Topicstarter

Berichten
5.274
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien

Eindhoven, Nederland

dan komt deze error:
Parse error: syntax error, unexpected T_REQUIRE_ONCE, expecting ( in /home/snabbonl/domains/snabbo.nl/public_html/msnbot.php on line 41
0
Erik

Lid

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Regel 41: $woorden = array();
0
Wouterr

Lid · Topicstarter

Berichten
5.274
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien

Eindhoven, Nederland

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting , or ; in /home/snabbonl/domains/snabbo.nl/public_html/msnbot.php on line 58

sadley
0
Berichten
1.544
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
echo .nl2br(stripslashes($row[woord])). => .nl2br(stripslashes($row[antwoord])).);;
1 teveel.
0
Wouterr

Lid · Topicstarter

Berichten
5.274
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien

Eindhoven, Nederland

nog steeds deze error:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting , or ; in /home/snabbonl/domains/snabbo.nl/public_html/msnbot.php on line 58
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000].nl2br(stripslashes($row[[/COLOR]woord[COLOR= #DD0000]])). => .nl2br(stripslashes($row[[/COLOR]antwoord[COLOR= #DD0000]])).);[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #FF8000]// moet[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/nl2br"]nl2br[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]woord[/COLOR][COLOR= #007700]])).[/COLOR][COLOR= #DD0000]=> [/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/nl2br"]nl2br[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]antwoord[/COLOR][COLOR= #007700]])));[/COLOR]
?>
0
Wouterr

Lid · Topicstarter

Berichten
5.274
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien

Eindhoven, Nederland

hier is de link: http://snabbo.nl/msnbot.php maar moet nu ff gaan doei
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
je hebt een ) teveel aan eind van die regel die ik gafwink
0
Wouterr

Lid · Topicstarter

Berichten
5.274
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien

Eindhoven, Nederland

Kijk normaal is het dit:

// Hier de gehele woordenlijst
    $woorden = array( // Voeg alle woorden hieronder toe
        woord => Antwoord,
woord => Antwoord,
woord => Antwoord,
woord => Antwoord);
    $anders = Wij zijn nog bezig met deze BOT!; // Dit wordt gezegd als de bot het niet snapt


En toen wou ik het met behulp van een database doen en dit wa waar ik mee begon:

$woorden = array( // Voeg alle woorden hieronder toe
require_once(connect.php);
    $sql = "
        SELECT woord, antwoord
        FROM msnbot
        ";
    if (!$res = mysql_query ($sql)) {
        echo FORUMCODE0;
    }
    else {
        $tellen = mysql_num_rows($res);
        $teller = 0; // teller start met 0
        while ($row = mysql_fetch_assoc ($res)) {
            $teller++; // teller eentje verhogen (1ste is dus nummer 1, 2de nnummer 2, etc..)
            if($teller == $tellen){ 
                echo .nl2br(stripslashes($row[woord])). => .nl2br(stripslashes($row[antwoord])).);;
            }else{
                echo .nl2br(stripslashes($row[woord])). => .nl2br(stripslashes($row[antwoord])).,;
            }
        }
    }
    $anders = Wij zijn nog bezig met deze BOT!; // Dit wordt gezegd als de bot het niet snapt


En nu heb ik dit:

$woorden = array();
require_once(connect.php);
    $sql = "
        SELECT woord, antwoord
        FROM msnbot
        ";
    if (!$res = mysql_query ($sql)) {
        echo FORUMCODE1;
    }
    else {
        $tellen = mysql_num_rows($res);
        $teller = 0; // teller start met 0
        while ($row = mysql_fetch_assoc ($res)) {
            $teller++; // teller eentje verhogen (1ste is dus nummer 1, 2de nnummer 2, etc..)
            if($teller == $tellen){ 
                echo nl2br(stripslashes($row[woord])).=> .nl2br(stripslashes($row[antwoord]));
            }else{
                echo .nl2br(stripslashes($row[woord])). => .nl2br(stripslashes($row[antwoord])).,;
            }
        }
    }
    $anders = Wij zijn nog bezig met deze BOT!; // Dit wordt gezegd als de bot het niet snapt


Die script zou er voor moeten zorgen dat de laatste met een ); en alle andere met , maar dat werkt niet?
0
Erik

Lid

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]config.php[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$woorden[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR]
[COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM msn_bot"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$fetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]))
{[/COLOR]
     
     [COLOR= #0000BB]$woorden[/COLOR][COLOR= #007700][] =[/COLOR] [COLOR= #0000BB]$fetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]woord[/COLOR][COLOR= #007700]];

}[/COLOR]
?>


Zoiets?
0
Berichten
3.283
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Op regel 40 heb je dit:
$woorden = array( // Voeg alle woorden hieronder toe

veranderen naar:

$woorden = array(); // Voeg alle woorden hieronder toe
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren