Posted By

tmort on 07/06/09


Tagged


Versions (?)

PHP Help


 / Published in: PHP
 

Help! I can't get the bottom lines of code to work!

  1. <?php
  2. $con = mysql_connect("localhost", "username", "password");
  3. if (!$con)
  4. {
  5. die('Could not connect: ' . mysql_error());
  6. }
  7.  
  8. mysql_select_db("database", $con);
  9.  
  10. $title = addslashes("$_POST[title]");
  11. $entry = addslashes("$_POST[entry]");
  12.  
  13.  
  14. $sql="INSERT INTO wp_revoked (id, your_name, your_mancard, your_email, rev_name, rev_email, title, entry)
  15. VALUES
  16. ('$_POST[id]','$_POST[your_name]','$_POST[your_number]','$_POST[your_email]','$_POST[rev_name]','$_POST[rev_email]','$title','$entry')";
  17.  
  18. if (!mysql_query($sql,$con))
  19. {
  20. die('Error: ' . mysql_error());
  21. }
  22. echo "<br />";
  23. ?>
  24.  
  25. <?php
  26.  
  27. //This is how you get it back out.
  28. $con = mysql_connect("localhost", "username", "password");
  29. if (!$con)
  30. {
  31. die('Could not connect: ' . mysql_error());
  32. }
  33.  
  34. mysql_select_db("database", $con);
  35.  
  36.  
  37. $query = "SELECT * FROM table ORDER BY id DESC LIMIT 1";
  38.  
  39. $date = date('Y-m-d H:i:s');
  40. $gmtdate = gmdate('Y-m-d H:i:s');
  41.  
  42. $result = mysql_query($query) or die(mysql_error());
  43.  
  44.  
  45. while ($row = mysql_fetch_array( $result ) ) {
  46. // Print out the contents of each row into a table
  47.  
  48. $rev_title = addslashes($row['title']);
  49.  
  50. $rev_name = $row['rev_name'];
  51. $your_name = $row['your_name'];
  52. $entry = addslashes($row['entry']);
  53. $all = "<ul><li><strong>Revokee:</strong> $rev_name</li> <br /> <li><strong>Submitted by:</strong> $your_name</li> <br /><li><strong>Reaso:</strong> $entry</li> <br /> <li><strong>Rate This: </strong></li></ul> ";
  54.  
  55. $ID = "";
  56. $post_title = echo $rev_title;
  57. $post_author = echo "7";
  58. $post_content = echo $all;
  59. $post_type = echo "post";
  60. $post_status = echo "publish";
  61. $comment_status = echo "publish";
  62. $post_date_gmt = echo $gmtdate;
  63. $post_date = echo $date;
  64. $post_category = echo "1";
  65. }
  66.  
  67. $con = mysql_connect("localhost", "username", "password");
  68. if (!$con)
  69. {
  70. die('Could not connect: ' . mysql_error());
  71. }
  72.  
  73. mysql_select_db("database", $con);
  74.  
  75.  
  76. $sql="INSERT INTO wp_4_posts (ID, post_author, post_date, post_date_gmt, post_content, post_title, post_status, comment_status, post_type, post_category)
  77. VALUES
  78. ('$ID','$post_title','$post_author','$post_content','$post_type','$post_status','$comment_status','$post_date_gmt','$post_date','$post_category')";
  79.  
  80. if (!mysql_query($sql,$con))
  81. {
  82. die('Error: ' . mysql_error());
  83. }
  84. echo "Revocation Submitted<br />";
  85.  
  86. ?>

Report this snippet  

You need to login to post a comment.