Probleem php?

Gestart doorMarv29 reacties121 weergaven

30 berichten · pagina 1 van 2

Marv

Lid · Topicstarter

Berichten
3.092
Reputatie
1
Punten
0,21
Lid sinds
Laatst gezien
Hallo,
ik ben bezig met een kliklink script, die heb ik uit een open source iets gehaald.

maar nu stuit ik op het volgende probleem:

[COLOR= #0000BB]<?php
$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"select * from leden where id=$_GET[id]"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700])) {[/COLOR]
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE leden SET punten=punten+$klikje WHERE id=$_GET[id]"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE leden SET verkocht=verkocht+1 WHERE id=$_GET[id]"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE stats SET kliks=kliks+1"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE stats SET punten=punten+$klikje"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE `stats` SET punten=punten+$klikje"[/COLOR][COLOR= #007700]);[/COLOR]
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO kopers (ip, time, verkoperid, url) VALUES ($_SERVER[REMOTE_ADDR], UNIX_TIMESTAMP(), $_GET[id], $HTTP_REFERER)"[/COLOR][COLOR= #007700]);[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je hebt zojuist 1 punt gegeven aan de gebruiker met ID: $_GET[id]"[/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]"Punten konden niet worden gegeven."[/COLOR][COLOR= #007700];
    }
}[/COLOR] ?>


Hij geeft telkens aan You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near WHERE id=1 at line 1.

Hoe kan ik dit verhelpen?

Mvg
0
Berichten
994
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Door netter te scripten
0
Marv

Lid · Topicstarter

Berichten
3.092
Reputatie
1
Punten
0,21
Lid sinds
Laatst gezien
Report wink
0
Berichten
435
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Zo misschien:

[COLOR= #0000BB]<?php
$id[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]];[/COLOR] 

[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"select * from leden where id=$id"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700])) {[/COLOR]
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE leden SET punten=punten+$klikje WHERE id=$id"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE leden SET verkocht=verkocht+1 WHERE id=$id"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE stats SET kliks=kliks+1"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE stats SET punten=punten+$klikje"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE `stats` SET punten=punten+$klikje"[/COLOR][COLOR= #007700]);[/COLOR]
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO kopers (ip, time, verkoperid, url) VALUES ($_SERVER[REMOTE_ADDR], UNIX_TIMESTAMP(), $id, $HTTP_REFERER)"[/COLOR][COLOR= #007700]);[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je hebt zojuist 1 punt gegeven aan de gebruiker met ID: $id"[/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]"Punten konden niet worden gegeven."[/COLOR][COLOR= #007700];
    }
}[/COLOR] ?>
0
Berichten
1.054
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Als ik jou was zou ik gaan leren om netter te scripten, dus FROM ipv from.. Je kan wel denken onzin maar als je t ooit gaat verkopen krijg je het zo niet verkocht emo
0
Berichten
435
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Het maakt niet echt veel uit... Het hoeft niet persee dat die from, FROM wordt...
Als hij dit prettig vindt werken.
0
Berichten
1.054
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nee maar het staat veel netter en is veel overzichtelijker, ik geef m enkel tips hoor wink
0
Marv

Lid · Topicstarter

Berichten
3.092
Reputatie
1
Punten
0,21
Lid sinds
Laatst gezien
Ik heb dit niet gescript als je goed leest.
Zat in een source, en ik vraag Hoe ik het oplos, als ik tips vroeg had ik dat wel gezegd
0
Berichten
1.054
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Als je even vertelt welke source kan ik je wellicht verder helpen emo
0
Berichten
435
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hdradio schreef:
Als je even vertelt welke source kan ik je wellicht verder helpen emo
Dat maakt niks uit emo
0
Berichten
1.054
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Stanieboy schreef:
Eerdere citaten tonen
Hdradio schreef:
Als je even vertelt welke source kan ik je wellicht verder helpen emo
Dat maakt niks uit emo
Ja toch wel ik heb liever wat meer informatie dan een paar regels
0
Berichten
435
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Je kan gewoon helpen zonder die info. Het is gewoon een qeury die niet werkt, en het ligt aan dat script, dan hoef je toch niet meer info te hebben.

@Efferinie, werkt hij al?
0
Marv

Lid · Topicstarter

Berichten
3.092
Reputatie
1
Punten
0,21
Lid sinds
Laatst gezien
nog niet.
0
Berichten
435
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Zo misschien:

[COLOR= #0000BB]<?php
$id[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM leden WHERE id=$id"[/COLOR][COLOR= #007700]);[/COLOR]
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700])) {[/COLOR]
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE leden SET punten=punten+$klikje WHERE id=$id"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE leden SET verkocht=verkocht+1 WHERE id=$id"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE stats SET kliks=kliks+1"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE stats SET punten=punten+$klikje"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE `stats` SET punten=punten+$klikje"[/COLOR][COLOR= #007700]);[/COLOR]
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO kopers (ip, time, verkoperid, url) VALUES ($_SERVER[REMOTE_ADDR], UNIX_TIMESTAMP(), $id, $HTTP_REFERER)"[/COLOR][COLOR= #007700]);[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je hebt zojuist 1 punt gegeven aan de gebruiker met ID: $id"[/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]"Punten konden niet worden gegeven."[/COLOR][COLOR= #007700];
    }
}[/COLOR] ?>
0
Marv

Lid · Topicstarter

Berichten
3.092
Reputatie
1
Punten
0,21
Lid sinds
Laatst gezien
Nee, er is iets niet goed met:

$result = mysql_query("SELECT * FROM leden WHERE id=$id");
    if ($row = mysql_fetch_array($result)) {
   mysql_query("UPDATE leden SET punten=punten+$klikje WHERE id=$id") or die(mysql_error());
    mysql_query("UPDATE leden SET verkocht=verkocht+1 WHERE id=$id") or die(mysql_error());


Hij geeft telkens aan You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near WHERE id=1 at line 1.

Mvg
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