Nieuws Commentaar script

Gestart doorShahiem8 reacties50 weergaven

9 berichten · pagina 1 van 1

Shahiem

Lid · Topicstarter

Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik probeerde een nieuws commentaar script te maken, maar dat lukt niet echt.

Foutmelding:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/vol9/byethost12.com/b12_3698192/htdocs/nwcomment.php on line 25

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/vol9/byethost12.com/b12_3698192/htdocs/nwcomment.php on line

En hij geeft ook aan dat die id niet is gevonden , terwijl hij er wel is..

Code:

[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/session_is_registered"]session_is_registered[/URL][COLOR= #007700]([/COLOR]myusername[COLOR= #007700])){[/COLOR]
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"location:main_login.php?msg=nieuws"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/exit"]exit[/URL][COLOR= #007700]();
}[/COLOR]

[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]header.tpl[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/include"]include[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]data.inc[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$host[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$username[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$password[/COLOR][COLOR= #007700])[/COLOR]or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Kan geen verbinding maken met database, probeer later opnieuw.[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"$db_name"[/COLOR][COLOR= #007700])[/COLOR]or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Kan de database niet vinden, probeer later opnieuw."[/COLOR][COLOR= #007700]);[/COLOR]


[COLOR= #0000BB]$id[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$id[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$id[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$id[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_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 id,datum,bericht,titel FROM nieuws"[/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]$result[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][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]


[COLOR= #0000BB]$count[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]);[/COLOR]


[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$count[/COLOR][COLOR= #007700]!==[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700]){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]De door u opgevraagde poll bestaat helaas niet. Ga terug naar de vorige pagina, of gebruik de zoekmachine.[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]footer.tpl[/COLOR][COLOR= #007700];[/COLOR] 
[URL="http://www.php.net/exit"]exit[/URL][COLOR= #007700]();
}[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<p><h2>[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]</h2></p>[/COLOR][COLOR= #007700];[/COLOR]



[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<h3 id="comments">Reacties</h3>[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$sql_comment[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"SELECT * FROM nieuws_reacties WHERE id=$id"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$result_comment[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql_comment[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$count_comment[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result_comment[/COLOR][COLOR= #007700]);[/COLOR]


[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$count_comment[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700]){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Er zijn geen recties voor deze poll.[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$error[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #DD0000]"nocomments"[/COLOR][COLOR= #007700];
}[/COLOR]



[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]  <ol class="commentlist">[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row_comment[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result_comment[/COLOR][COLOR= #007700]))
  {[/COLOR]
  ?>
                <li class="alt" id="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row_comment[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]];[/COLOR] ?>">
                    
                    <cite>
                        <img alt="" src="images/gravatar.jpg" class="avatar" height="40" width="40">            
                        <a href="#">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row_comment[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR] ?></a> Says: <br>                
                        <span class="comment-data"><a href="#[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row_comment[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]];[/COLOR] ?>" title="">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row_comment[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]date[/COLOR][COLOR= #007700]];[/COLOR] ?> op [COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row_comment[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]time[/COLOR][COLOR= #007700]];[/COLOR] ?></a> </span>

                    </cite>
                            
                    <div class="comment-text">
                        <p>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row_comment[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]comment[/COLOR][COLOR= #007700]];[/COLOR] ?></p>
                    </div>        
                    
                </li>

[COLOR= #0000BB]<?php[/COLOR]
  [COLOR= #007700]}[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</ol>[/COLOR]

?>

             <h3 id="respond">Plaats een Reactie</h3>                
            
            <form action="poll_addcomment.php" method="post" id="commentform">        
                                <INPUT TYPE=HIDDEN NAME="poll_id" value="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$poll_id[/COLOR][COLOR= #007700];[/COLOR] ?>">                            
                <p>
                    <label for="message">Uw bericht</label><br>
                    <textarea id="message" name="message" rows="10" cols="20" tabindex="1"></textarea>
                </p>    
            
                <p class="no-border">
                    <input class="button" value="Submit" tabindex="2" type="submit">                 
                </p>
                    
            </form>        
[COLOR= #0000BB]<?php[/COLOR]


[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]footer.tpl[/COLOR][COLOR= #007700];[/COLOR] 
?>
0
Berichten
1.160
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
$sql = "SELECT id,datum,bericht,titel FROM nieuws" or die (mysql_error()); 

$result = mysql_query($sql);
0
Shahiem

Lid · Topicstarter

Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nog steeds niet
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ordian schreef:
$sql = "SELECT id,datum,bericht,titel FROM nieuws"; 

$result = mysql_query($sql) or die (mysql_error());
je hebt $result=mysql_query($sql);, maar je geeft nergens aan wat $sql is
0
Shahiem

Lid · Topicstarter

Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hij kan de artikel niet vinden

De eerste fout is wel opgelosst
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
je hebt:

if($count!==1){

dus als er niet 1 artikel is, dan bestaat hij niet?

of bedoel je dat hij het ding moet selecteren met het id $id?
0
Shahiem

Lid · Topicstarter

Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
De mede-eigenaar had een script gemaakt voor als je poll hebt dat je dan een reactie kan toevoegen , en dat kopieerde ik en probeerde er een nieuws commentaar script van te maken.
0
Bas

Lid

Berichten
1.081
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
regel 4 is wel een beetje ouderwets,
kan je gewoon zo doen:
if(!isset($_SESSION[myusername]) {


volgens mij
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Baseldekker:
regel 4 is wel een beetje ouderwets,
kan je gewoon zo doen:
if(!isset($_SESSION[myusername]) {


volgens mij

ja,
in php 6 zit het zelfs niet meer emo
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