Script probleem

Gestart doorBjarnootjuh45 reacties192 weergaven

46 berichten · pagina 1 van 4

Bjarnootjuh

Lid · Topicstarter

Berichten
7.806
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hoi,

Ik heb een script.

Iemand anders heeft het gemaakt en ik kocht het maar ineens doet het script het niet meer.
Hier: http://djbjarn.nl/rds/rds.php

die is wit. Elke 5 seconden moet er een dia uit de db worden gehaald en er staan 3 teksten al in.

Ik krijg het niet opgelost. Hulp is welkom!

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]config.php[/COLOR][COLOR= #007700]);[/COLOR]


[COLOR= #0000BB]$query2[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT * FROM dias"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$resultaat2[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query2[/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]
[COLOR= #0000BB]$aantal[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$resultaat2[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$id2[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$aantal[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT * FROM dias WHERE id = $id2"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$resultaat[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/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]$aantal[/COLOR] [COLOR= #007700]>=[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700])
{[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$rij[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$resultaat[/COLOR][COLOR= #007700]))
{[/COLOR]    

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000][/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$rij[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]content[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000][/COLOR][COLOR= #007700];
}
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{
}[/COLOR]

?>
<meta http-equiv="refresh" content="5">
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
- Voeg error_reporting en display_errors toe.
- Pas goede foutafhandeling toe in je script. or die() is niet de beste manier.
- MySQL kent ook een RAND() functie. Dit werkt makkelijker dan wat je nu hebt.
- Wat is het nut van lege strings aan een variabele koppellen op lijn 24?
0
Bjarnootjuh

Lid · Topicstarter

Berichten
7.806
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Aarclay schreef:
- Voeg error_reporting en display_errors toe.
- Pas goede foutafhandeling toe in je script. or die() is niet de beste manier.
- MySQL kent ook een RAND() functie. Dit werkt makkelijker dan wat je nu hebt.
- Wat is het nut van lege strings aan een variabele koppellen op lijn 24?
Kan je voor mij het script aanpassen? Hoe het zou moeten. En die lege string daar komt de tekst uit de database.
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Bjarnootjuh schreef:
Eerdere citaten tonen
Aarclay schreef:
- Voeg error_reporting en display_errors toe.
- Pas goede foutafhandeling toe in je script. or die() is niet de beste manier.
- MySQL kent ook een RAND() functie. Dit werkt makkelijker dan wat je nu hebt.
- Wat is het nut van lege strings aan een variabele koppellen op lijn 24?

Kan je voor mij het script aanpassen? Hoe het zou moeten. En die lege string daar komt de tekst uit de database.
Ik zal hem wel goedmaken!
0
Berichten
907
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik weet niet zeker maar moet mysql_fetch_array niet mysql_fetch_assoc zijn?
Want je zegt namelijk $rij[content] en dat kan dacht ik alleen met een associative array, en met een normale array kun je het alleen maar aanroepen met een integer. Zoals $rij[2].
Je kan het proberen, ik weet het niet zeker.
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]config.php[/COLOR][COLOR= #007700]);[/COLOR]

    [COLOR= #0000BB]$qLid[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM dias ORDER BY RAND() LIMIT 1"[/COLOR][COLOR= #007700]);[/COLOR] 
  [URL="http://www.php.net/while"]while[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$aLid[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$qLid[/COLOR][COLOR= #007700]))
    {[/COLOR] 
     ?>
<?=$aLid[content]?>
  [COLOR= #0000BB]<?[/COLOR]
  [COLOR= #007700]}[/COLOR] [COLOR= #FF8000]//while afsluiten[/COLOR]
  [URL="http://www.php.net/mysql_free_result"]mysql_free_result[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$qLid[/COLOR][COLOR= #007700]);[/COLOR] 
  ?>
<meta http-equiv="refresh" content="5">


toevoeging op 1 maart 2012, 16:53:13:
Vanaf welke kolom moeten ze worden opgehaald?
0
Bjarnootjuh

Lid · Topicstarter

Berichten
7.806
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
de kolom content
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Nu zou hij het moeten doen met dat scriptje.

toevoeging op 1 maart 2012, 16:55:49:
haal de laatst ?> weg
0
Bjarnootjuh

Lid · Topicstarter

Berichten
7.806
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oke, deze gaat op volgorde? En als dat zo is werkt hij!
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Bjarnootjuh schreef:
Oke, deze gaat op volgorde? En als dat zo is werkt hij!
Nee, hij gaat op Random
0
Bjarnootjuh

Lid · Topicstarter

Berichten
7.806
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
O hoe kan ik dat veranderen?
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Bjarnootjuh schreef:
O hoe kan ik dat veranderen?
Het is onmogelijk om elke keer de pagina te refreshen en hem op id laten gaan. Hiervoor zal je sessies voor moeten gebruiken die registreren welk id de bezoeker al heeft gehad. Alle gehad? Overnieuw van 1 naar einde.
0
Bjarnootjuh

Lid · Topicstarter

Berichten
7.806
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dan laat ik dit maar zo. Bedankt!

toevoeging op 1 maart 2012, 17:03:01:
Een vraagje tussendoor:

Hoe kan je het maximaal aantal karakters in een text field neerzetten met php? Anders zetten djs te lange berichten neer.
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
kan toch mooier, waarom steeds PHP afsluiten yummie
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]config.php[/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 content FROM dias ORDER BY RAND() LIMIT 1"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]) {[/COLOR]
 [URL="http://www.php.net/while"]while[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$Lid[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700])){[/COLOR]
  [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$aLid[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]content[/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]"Error: "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]();
}[/COLOR]
  ?>
<meta http-equiv="refresh" content="5">


Let er wel op dat die meta-tag in je head-sectie staat.
0
Thom

Lid

Berichten
10.654
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Je kan dit ook veel mooier met jQuery maken..
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