Billedet fra Database
http://localhostr.com/files/bxCOaer/capture.pngHer er hjemmeside som jeg har kopie fra,
http://www.phpeasystep.com/phptu/15.htmlJeg prøve at få det mest af det over på dansk.
(men det gå ikke vildt godt lige nu)
Det er sådan at man kan skrive på enes profil/ bruger på han's profil for siden
og der har jeg fundet frem til en simple php guestebook
- <table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
- <tr>
- <td><strong>Test Sign Guestbook </strong></td>
- </tr>
- </table>
- <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
- <tr>
- <form id="form1" name="form1" method="post" action="addguestbook.php">
- <td>
- <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
- <tr>
- <td width="117">navn</td>
- <td width="14">:</td>
- <td width="357"><input name="navn" type="text" id="navn" size="40" /></td>
- </tr>
- <td valign="top">Skrevet</td>
- <td valign="top">:</td>
- <td><textarea name="skrevet" cols="40" rows="3" id="skrevet"></textarea></td>
- </tr>
- <tr>
- <td> </td>
- <td> </td>
- <td><input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" /></td>
- </tr>
- </table>
- </td>
- </form>
- </tr>
- </table>
- <table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
- <tr>
- <td><strong><a href="viewguestbook.php">View Guestbook</a> </strong></td>
- </tr>
- </table>
så er der den her som hedder addguestbook.php
- <?php
- $host="localhost"; // Host name
- $username="web146-a-foru-47"; // Mysql username
- $password=" "; // Mysql password
- $db_name="web146-a-foru-47"; // Database name
- $tbl_name="guestbook"; // Table name
-
- // Connect to server and select database.
- mysql_connect('localhost','web146-a-foru-47',' ') or die("cannot connect server ");
- mysql_select_db('web146-a-foru-47')or die("cannot select DB");
-
- $datetime=date("y-m-d h:i:s"); //date time
-
- $sql="INSERT INTO $tbl_name(name, email, comment, datetime)VALUES('$name', '$email', '$comment', '$datetime')";
- $result=mysql_query($sql);
-
- //check if query successful
- if($result){
- echo "Successful";
- echo "<BR>";
- echo "<a href='viewguestbook.php'>View guestbook</a>"; // link to view guestbook page
- }
-
- else {
- echo "ERROR";
- }
-
- mysql_close();
- ?>
Den her vise dem som er skrevet. mener jeg
- <table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
- <tr>
- <td><strong>View Guestbook | <a href="guestbook.php">Skriv i Gæstebog</a> </strong></td>
- </tr>
- </table>
- <br>
-
- <?php
-
- $host="localhost"; // Host name
- $username="web146-a-foru-47"; // Mysql username
- $password=" "; // Mysql password
- $db_name="web146-a-foru-47"; // Database name
- $tbl_name="guestbook"; // Table name
-
- // Connect to server and select database.
- mysql_connect('localhost','web146-a-foru-47',' ') or die("cannot connect server ");
- mysql_select_db('web146-a-foru-47')or die("cannot select DB");
-
- $sql="SELECT * FROM $tbl_name";
- $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">navn</td>
- <td width="14">:</td>
- <td width="357"><? echo $rows['navn']; ?></td>
- </tr>
- <tr>
- <td valign="top">Comment</td>
- <td valign="top">:</td>
- <td><? echo $rows['skrevet']; ?></td>
- </tr>
- <tr>
- <td valign="top">Data </td>
- <td valign="top">:</td>
- <td><? echo $rows['data']; ?></td>
- </tr>
- <tr>
- <td valign="top">Time </td>
- <td valign="top">:</td>
- <td><? echo $rows['time']; ?></td>
- </tr>
- </table></td>
- </tr>
- </table>
- <BR>
- <?
- }
- mysql_close(); //close database
- ?>
Når jeg prøve at sende noget så siger den "ERROR"
Indlæg senest redigeret d. 22.03.2011 17:30 af Bruger #16353