I tried using all of the methods above, but it still ends up blank...
If anyone here uses Yahoo! WebHosting, I clicked "View Source at Line..." in the PHP editor. The numbers are line numbers and the echo "checkpoint " . $i was to see what parts worked. This is what it gave me (once again, I edited out the MySQL username/password):
Code:
1 <?php
2 error_reporting(E_ALL);
3 ?>
4 <html>
5 <head>
6 <script language="javascript" type="text/javascript">
7 window.onload = function()
8 {
9 var trs = document.getElementsByTagName("tr");
10 for (var i = 0; i < trs.length; i++)
11 {
12 var tr = document.getElementsByTagName("tr")[i];
13 if (i == (parseInt(trs.length) - 1))
14 {
15 tr.innerHTML += '<a name="Most_Recent"></a>';
16 }
17
18 }
19 }
20 </script>
21
22 <title>Untitled</title>
23
24 </head>
25 <body>
26 <h1>Posts</h1>
27 <a href="#Most_Recent">Most Recent</a> <a href="#Quick_Reply">Quick Reply</a> <a href="forum_form.htm">Advanced Reply</a><br />
28 <?
29 echo 'checkpoint 1';
30 $con = mysql_connect("localhost","admin","pass");
31 if (!$con)
32 {
33 die('Could not connect: ' . mysql_error());
34 }
35
36 mysql_select_db("forum");
37 echo 'checkpoint 2';
38 $result = mysql_query("SELECT * FROM posts");
39
40 echo "<table border='1'>
41 <tr>
42 <th>Username</th>
43 <th>Title</th>
44 <th>Post</th>
45 </tr>";
46 echo 'checkpoint 3';
47 $i = 4;
48 while($row = mysql_fetch_array($result))
49 {
50 echo "<tr>";
51 echo "<td>" . $row['Username'] . "</td>";
52 echo "<td>" . $row['Title'] . "</td>";
53 echo "<td>" . $row['Post'] . "</td>";
54 echo "</tr>";
55 echo 'checkpoint ' . $i;
56 $i++
57 }
58 echo "</table>";
59 mysql_close($con);
60 echo 'checkpoint ' . $i;
61 $i++
62 ?>
63 <br /><button onclick="location.reload()">Reload Posts</button>
64 <br /><a name="Quick_Reply">Quick Reply:
65 <form action="" method="post">
66 Username: <input name="username" id="username" type="text" /><br />
67 Password: <input name="pass" id="pass" type="password" /><br />
68 Post title: <input name="title" id="title" type="text" /> Text: <textarea name="post" id="post"></textarea>
69 <input type="submit" value="Submit"/>
70 </form></a>
71 <a href="forum_form.htm">Advanced Reply</a>
72 <?php
73 $username = $_POST["username"];
74 $pass = $_POST["pass"];
75 $title = $_POST["title"];
76 $post = $_POST["post"];
77 $con2 = mysql_connect("localhost","admin","pass");
78 echo 'checkpoint ' . $i;
79 $i++
80 if (!$con2)
81 {
82 die('Could not connect: ' . mysql_error());
83 }
84
85 mysql_select_db("forum", $con2);
86 echo 'checkpoint ' . $i;
87 $i++
88 $result = mysql_query("SELECT * FROM users
89 WHERE username == $username");
90 while($row = mysql_fetch_array($result))
91 {
92 echo '<p>Trying ' . $row['username'] . '<img src="ajax-loader.gif" width="220" height="19">';
93 echo 'checkpoint ' . $i;
94 $i++
95 if (($row['username'] == $username) && ($row['password'] == $pass))
96 {
97 echo 'Login Succeeded! Posting<img src="wait.gif" alt="Animated Loading Symbol" name="posting" id="posting" width="32" height="32">';
98 sql();
99 echo 'Posted!';
100 break;
101 } else {
102 echo 'Login failed.'
103 }
104 echo 'Moving on...';
105 }
106 mysql_close($con2);
107 echo 'checkpoint ' . $i;
108 $i++
109 function sql() {
110 $con3 = @mysql_connect("localhost", "admin", "password");
111 echo 'checkpoint ' . $i;
112 $i++
113 if (!$con3) {
114 die( "Unable to connect to the
115 database server at this time." );
116 } else {
117 mysql_query("INSERT INTO forum (user, title, post)
118 VALUES ($username, $title, $post)");
119 echo 'checkpoint ' . $i;
120 $i++
121 }
122 mysql_close($con3);
123 }
124 ?>
125
126 </body>
127 </html>
128
129
130
131
PS. The phpMyAdmin for the MySQL is in the subdirectory "php". Is it necessary to change the code in any way?
Bookmarks