[php][mysql] Warning offset

Gestart doorFreestyle2 reacties32 weergaven

3 berichten · pagina 1 van 1

Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik kan nergens mijn fout vinden. Heb ook flink wat gegoogled maar heb niks gevonden wat mijn probleem oplost, of er naar leid dat ik het kan oplossen..

De error:

SCREAM: Error suppression ignored for

Warning: Illegal string offset ip in **wampwww******log.php on line 29


Php code: (log.php) regel 1 = regel 25
[COLOR= #0000BB]<?php
$lQ[/COLOR] [COLOR= #007700]=[/COLOR] Mysql[COLOR= #007700]::[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]SELECT * FROM logs[/COLOR][COLOR= #007700]);[/COLOR]
        
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<ul [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$class[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]>[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR]Mysql[COLOR= #007700]::[/COLOR]assoc[COLOR= #007700]([/COLOR][COLOR= #0000BB]$lQ[/COLOR][COLOR= #007700]) as[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700]) {[/COLOR]
        
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<li>[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]ip[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]</li>[/COLOR][COLOR= #007700];
        
        }[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</ul>[/COLOR][COLOR= #007700];[/COLOR]
?>


Mysql class stukje:
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/public"]public[/URL] [URL="http://www.php.net/static"]static[/URL] [COLOR= #007700]function[/COLOR] query[COLOR= #007700]([/COLOR][COLOR= #0000BB]$input[/COLOR][COLOR= #007700]) {[/COLOR]
        
        [COLOR= #0000BB]$q[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$input[/COLOR][COLOR= #007700]);[/COLOR]
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][COLOR= #0000BB]$q[/COLOR][COLOR= #007700]) {[/COLOR]
            [URL="http://www.php.net/return"]return[/URL] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]();
        }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
            [URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$q[/COLOR][COLOR= #007700];
        }
        
    }[/COLOR]

[URL="http://www.php.net/public"]public[/URL] [URL="http://www.php.net/static"]static[/URL] [COLOR= #007700]function[/COLOR] assoc[COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]) {[/COLOR]
        
        [URL="http://www.php.net/return"]return[/URL] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);
        
    }[/COLOR]
?>


Weet iemand dus wat ik fout doe???
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
kan je er niet beter dit van maken?
while($row = Mysql::assoc($lQ)) {

toevoeging op 3 augustus 2012, 15:28:48:
Wat je nu doet is de eerste rij ophalen, en voor elk veld van die rij krijg je de waarde terug. Die waarde is geen array, dus $row[ip] gaat nooit bestaan. Dat kun je zien als je gewoon .$row. doet ipv .$row[ip].
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Bedankt!!

Dit is indd ook beter smile alleen bij codeigniter doen ze het met foreach smile en daar was ik een tijdje mee bezig geweest
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