markus_omega
Gebruiker
- Lid geworden
- 23 apr 2007
- Berichten
- 56
ik probeer al een paar dagen een gastenboek op tezetten met php en mysql. ik ben vrij nieuw met php en databases en heb dus voor mijn gastenboek een tutorial gebruikt. http://www.phpeasystep.com/workshopview.php?id=15 maar ik blijf de zelde fout krijgen.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/soswe3/public_html/viewguestbook.php on line 23
hier onder zie je de code.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/soswe3/public_html/viewguestbook.php on line 23
hier onder zie je de code.
PHP:
<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td><strong>View Guestbook | <a href="guestbook.php">Sign Guestbook</a> </strong></td>
</tr>
</table>
<br>
<?php
$host="localhost"; // Host name
$username="soswe3_all"; // Mysql username
$password="allvisitors"; // Mysql password
$db_name="soswe3_test"; // Database name
$tbl_name="guestbook"; // Table name
// Connect to server and select database.
$dbh=mysql_connect ("localhost", "soswe3_all", "allvisitors") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("soswe3_test");
$sql="SELECT * FROM $soswe3_test";
$result=mysql_query($sql);
while($rows=mysql_fetch_array($result)){
?>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td><table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td>ID</td>
<td>:</td>
<td><? echo $rows['id']; ?></td>
</tr>
<tr>
<td width="117">Name</td>
<td width="14">:</td>
<td width="357"><? echo $rows['name']; ?></td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
<td><? echo $rows['email']; ?></td>
</tr>
<tr>
<td valign="top">Comment</td>
<td valign="top">:</td>
<td><? echo $rows['comment']; ?></td>
</tr>
<tr>
<td valign="top">Date/Time </td>
<td valign="top">:</td>
<td><? echo $rows['datetime']; ?></td>
</tr>
</table></td>
</tr>
</table>
<BR>
<?
}
mysql_close(); //close database
?>