Advertisement
Guest User

Untitled

a guest
Aug 7th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1.  
  2. <html>
  3. <head>
  4. <title>Test DB PHP Script</title>
  5. </head>
  6. <body>
  7. <?php
  8. //use PHP to connect MySQL
  9. echo "I hate pawdhp";
  10. $host = 'localhost';
  11. $user = 'zarycki2_g';
  12. $password = "CM12p0p";
  13. $dbconn = mysql_connect($host, $user, $password) or die ('Could not connect to
  14. database: ' . mysql_error());
  15. mysql_select_db('zarycki2_CaffeinateMe');
  16.  
  17. //get variables from POST
  18.  
  19. $author = $_POST['author'];
  20. $date = $_POST['date'];
  21. $rating = $_POST['rating'];
  22. $comments = $_POST['comments'];
  23.  
  24. //Find the Highest ID to get the next ID
  25. $query = "SELECT MAX(Review_ID) from Review";
  26. $result = mysql_query($query);
  27. if (!$result) {
  28. die('invalid query: ' . mysql_error());
  29. }
  30.  
  31. $row = mysql_fetch_array($result);
  32. $number = $row['MAX(Review_ID)'] + 1;
  33. echo $number ;
  34.  
  35.  
  36.  
  37. $query = "INSERT INTO Review(Review_ID, Author, Date, Rating, Comments) VALUES('$number','$author','$date','$rating','$comments')";
  38. $result = mysql_query($query);
  39. if (!$result) {
  40. die('Invalid query: ' . mysql_error());
  41. }
  42.  
  43.  
  44.  
  45. echo "lol";
  46.  
  47. mysql_close($dbconn);
  48. ?>
  49. </body>
  50. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement