Guest User

Untitled

a guest
Jul 18th, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. <?php
  2. //Open a new connection to the MySQL server
  3. $mysqli = new mysqli('localhost','createyo_james','password','createyo_TestDatabase');
  4.  
  5. //Output any connection error
  6. if ($mysqli->connect_error) {
  7. die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
  8. }
  9.  
  10. //values to be inserted in database table
  11. $NewsStory = $_POST["NewsStory"];
  12.  
  13. $query = "INSERT INTO products (NewsStory) VALUES(?)";
  14. $statement = $mysqli->prepare($query);
  15.  
  16. //bind parameters for markers, where (s = string, i = integer, d = double, b = blob)
  17. $statement->bind_param('s', $NewsStory);
  18.  
  19. if($statement->execute()){
  20. print 'Success! ID of last inserted record is : ' .$statement->insert_id .'<br />';
  21. }else{
  22. die('Error : ('. $mysqli->errno .') '. $mysqli->error);
  23. }
  24. $statement->close();
  25.  
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment