Jump to content

Bojak

Members
  • Posts

    57
  • Joined

  • Last visited

Everything posted by Bojak

  1. I also don't have action in the form. does that matter?
  2. <?php // Make a MySQL Connection mysql_connect("127.0.0.1", "root", "") or die(mysql_error()); mysql_select_db("users") or die(mysql_error()); $result = mysql_query("SELECT comments FROM users") or die(mysql_error()); while($row = mysql_fetch_assoc($result)){ if(!isset($dataString)){ $dataString = $row['comments'] or die(mysql_error()); } else{ $dataString .= "<br><br>{$row['commens']}" or die(mysql_error()); } } // http://forums.phpfreaks.com/topic/282059-comment-system/ $page = <<<PAGE <!DOCTYPE html> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <form name="input" action="" method="get"> <div id="commentsr"> $dataString </div> <textarea id="myMessage" name="comments" cols="30" rows="10" style="width: 400px; height: 83px;"></textarea> <input type="submit" value="Submit"> </form> </body> </html> PAGE; echo $page; ?> I changed lines 8, 11, 5 but im getting a new error. ( ! ) Parse error: syntax error, unexpected ';' in C:\wamp\www\comments.php on line 5
  3. <?php // Make a MySQL Connection mysql_connect("127.0.0.1", "root", "") or die(mysql_error()); mysql_select_db("users") or die(mysql_error()); $result = mysql_query("SELECT comments FROM users"); while($row = mysql_fetch_assoc($result)){ if(!isset($dataString)){ $dataString = $row['comments']; } else{ $dataString .= "<br><br>{$row['comments']}"; } } $page = <<<PAGE <!DOCTYPE html> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <form name="input" action="" method="get"> <div id="commentsr"> $dataString </div> <textarea id="myMessage" name="comments" cols="30" rows="10" style="width: 400px; height: 83px;"></textarea> <input type="submit" value="Submit"> </form> </body> </html> PAGE; echo $page; ?> mac_gyver where would I add it and what exactly would I add?
  4. Notice: Undefined variable: dataString in C:\wamp\www\comments.php on line 31 Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\wamp\www\comments.php on line 6 Muddy_Funster i was given the above errors when trying your code.
  5. <!DOCTYPE html> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <?php // Make a MySQL Connection mysql_connect("127.0.0.1", "root", "") or die(mysql_error()); mysql_select_db("user") or die(mysql_error()); // Get all the data from the "example" table $result = mysql_query("SELECT comments FROM comments") or die(mysql_error()); echo "<table border='1'>"; echo "<tr> <th>Name</th> <th>Age</th> </tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['comments']; echo "</td><td>"; } echo "</table>"; ?> </head> <body> <form name="input" action="" method="get"> <textarea id="myMessage" name="comments" cols="30" rows="10" style="width: 400px; height: 83px;"></textarea> <input type="submit" value="Submit"> </form> </body> </html> Table 'users.comments' doesn't exist, i dont know why its saying this. thats not even my table name. my table name is users.
  6. would it at least echo from the db like that?
  7. <!DOCTYPE html> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <?php // Make a MySQL Connection mysql_connect("127.0.0.1", "root", "") or die(mysql_error()); mysql_select_db("users") or die(mysql_error()); $result = mysql_query("SELECT comments FROM users"); ?> </head> <body> <form name="input" action="" method="get"> <div id="commentsr"> <?php echo $result["comments"]; ?> </div> <textarea id="myMessage" name="comments" cols="30" rows="10" style="width: 400px; height: 83px;"></textarea> <input type="submit" value="Submit"> </form> </body> </html> i am building a comment system that refuses to put the comment in the db and echo the comment to a page. i tried putting the comment in a div. that could also be a wrong way of doing it.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.