Php vraag error mysql_fetch

Gestart doorPropje24 reacties48 weergaven

25 berichten · pagina 2 van 2

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Is Nieuws (waarvandaan je alles selecteert ( * )) ook daadwerkelijk met een hoofdletter N? En waarom random ( RAND() ) orderen terwijl je eerst zegt dat ie van een bepaald id alle gegevens op moet halen?

Beetje tegenstrijdig allemaal, denk daar even aan en misschien zit daar de oplossing wel in. smile
0
Propje

Lid · Topicstarter

Berichten
2.517
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ja hij is met een hoofdletter N random rand heb ik omdat ik om de elke 4 sec er een nieuwe komt. dus hij zoekt ze uit de db.
0
Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Er staat: ORDER BY RAND() maar niet wat hij random moet sorteren, als je bijv. op random id zou sorteren wordt het:

ORDER BY id RAND()

Succes smile
0
Propje

Lid · Topicstarter

Berichten
2.517
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dan krijg ik de tekst uit de db niet meer te zien confused
0
Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dan kloppen er meerdere dingen niet... Wat geeft de error aan?
0
Berichten
5.498
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Moet die mysql_fetch_array niet in een while staan?
0
Propje

Lid · Topicstarter

Berichten
2.517
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb nu dit

[COLOR= #0000BB]<?php[/COLOR]
                 [URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]config.php[/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]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]]) &&[/COLOR] [URL="http://www.php.net/is_numeric"]is_numeric[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][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 Nieuws where id="[/COLOR][COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]" ORDER BY id RAND() LIMIT 1"[/COLOR][COLOR= #007700]);[/COLOR] 
                 [URL="http://www.php.net/while"]while[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$nieuws[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])){[/COLOR]
                            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$nieuws[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]];[/COLOR]
                                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br />[/COLOR][COLOR= #007700];[/COLOR]
                        [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/substr"]substr[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$nieuws[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]],[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]50[/COLOR][COLOR= #007700]);[/COLOR]
                        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br />[/COLOR][COLOR= #007700];[/COLOR]
                        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<a href="nieuws.php?id=[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$nieuws[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"id"[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]><input type="image" src="images/check.png" style="margin-left: 97px; margin-top: 17px color: #000; border: none;" name="image" width="81" height="23"></a>[/COLOR][COLOR= #007700];

                               }
                       }[/COLOR]
                 ?>


Maar dan zie ik geen tekst op mijn website confused
0
Berichten
5.498
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Staat er wel iets in de database yummie?
Probeer anders een zo simpel mogelijk te werken om te kijken of je Query wel kopt;

[COLOR= #0000BB]<?php[/COLOR]
                 [URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]config.php[/COLOR][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 Nieuws where id="[/COLOR][COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]" ORDER BY id RAND() LIMIT 1"[/COLOR][COLOR= #007700]);[/COLOR] 
                 [URL="http://www.php.net/while"]while[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$nieuws[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])){[/COLOR]
                            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$nieuws[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]];
                               }[/COLOR]
                       
                 ?>


Als dit werkt werkt ligt het dus iig niet aan de query
0
Propje

Lid · Topicstarter

Berichten
2.517
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dan krijg ik deze fout

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/a2829566/public_html/test.php on line 5
0
Berichten
5.498
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Propje schreef:
Dan krijg ik deze fout
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/a2829566/public_html/test.php on line 5

Het ligt aan je MYSQL Query wink
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