Fout in query

Gestart doorWouterp18 reacties94 weergaven

19 berichten · pagina 1 van 2

Wouterp

Lid · Topicstarter

Berichten
1.631
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Heey,

Ben al tig uur bezig met een script, en loop nu tegen klein probleempje,

[COLOR= #0000BB]<?php $query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]INSERT INTO visitors 
                        (
                            id, ip, host_name, times_visited
                         )VALUES (
                            [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$id[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000],[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$ip[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000],[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$host[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000],[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]
                        )
                    [/COLOR][COLOR= #007700]);[/COLOR]
?>


Er word niks in DB gezet, Waarschijnlijk is het een slordigheidsfoutje maarja,
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
mysql_query nergens gebruikt?
0
Wouterp

Lid · Topicstarter

Berichten
1.631
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Weinig slaap veel coden, werkt nog steeds niet.
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
$query =
Weghalen
0
Berichten
2.609
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Foutafhandeling staat nergens?
0
Berichten
398
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik denk dat je ergens een afsluiting } vergeten bent yummie
0
Berichten
2.609
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
gaan we nou allemaal gokken wat het probleem kan zijn? Doe eerst die foutafhandeling er maar bij emo
0
Wouterp

Lid · Topicstarter

Berichten
1.631
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Foutafhandeling staat er onder, Liet alleen de query zien.
0
Berichten
2.609
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nou wat is de error?
0
Wouterp

Lid · Topicstarter

Berichten
1.631
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Leachers gonna leach:

Hier het hele script heb half jaar niet coded... Valt me toch weer vies tegen bloos
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]/**
 * @author Wouter Polman
 * @copyright 2012
 * @project Increasing safety
*/[/COLOR]
[URL="http://www.php.net/require_once"]require_once[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]../include/db_connect.php[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$id[/COLOR]    [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_insert_id"]mysql_insert_id[/URL][COLOR= #007700]();[/COLOR]
[COLOR= #0000BB]$ip[/COLOR]   [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$host[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/gethostbyaddr"]gethostbyaddr[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$ip[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$select[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]
                    SELECT times_visited
                    FROM [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$db_name[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000] 
                    WHERE ip=[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$ip[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]
         [/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$select[/COLOR][COLOR= #007700])){[/COLOR]
    [COLOR= #0000BB]$value[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
    [COLOR= #0000BB]$value[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$select[/COLOR][COLOR= #007700]+[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700];
}[/COLOR]


[COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]INSERT INTO visitors 
                        (
                            id, ip, host_name, times_visited
                         )VALUES (
                            [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$id[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000],[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$ip[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000],[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$host[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000],[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]
                        )
                    [/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])){[/COLOR]
    [COLOR= #0000BB]$vistors_update[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]succes[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
    [COLOR= #0000BB]$visitors_update[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]fail[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<b>Could not update visitors database</b><br />[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]().[/COLOR][URL="http://www.php.net/die"]die[/URL][COLOR= #007700]();
}[/COLOR]
?>
0
Berichten
5.274
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien

Eindhoven, Nederland

Wat is de error............?
0
Berichten
398
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oke, dat de helft van de bestand niet gescript was yummie
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Wattefak?

Kan je ook concreet even antwoorden op onze vragen?
En voeg nou eens die foutafhandeling toe, door met if-else te kijken wat mysql_query terug geeft, Als dit false is, toon je mysql_error()
0
Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Als je een query doet doe je dit met "" en niet met . Ook geef je geen ID mee bij het inserten, hiervoor gebruik je A.i
0
Thom

Lid

Berichten
10.654
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php $query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO visitors 
                        (
                            id, ip, host_name, times_visited
                         )VALUES (
                            "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$id[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]","[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$ip[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]","[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$host[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]","[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"
                        )
                    "[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]){[/COLOR]
        [COLOR= #FF8000]// toegevoegd[/COLOR]
[COLOR= #007700]}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]();
}[/COLOR]

?>


Ofzo yummie
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