Advertisement
ujiajah1

create_table.php

Jun 18th, 2016
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.66 KB | None | 0 0
  1. <?php
  2. $dbhost = 'localhost';
  3. $dbuser = 'root';
  4. $dbpass = '';
  5. $conn = mysql_connect($dbhost, $dbuser, $dbpass);
  6. if(! $conn )
  7. {
  8.   die('Could not connect: ' . mysql_error());
  9. }
  10. echo 'Connected successfully<br />';
  11. $sql = "CREATE TABLE tamu( ".
  12.        "id_bukutamu INT(4) NOT NULL AUTO_INCREMENT, ".
  13.        "nama VARCHAR(100) NOT NULL, ".
  14.        "email VARCHAR(100) NOT NULL, ".
  15.        "isi text NOT NULL, ".
  16.        "PRIMARY KEY ( id_bukutamu )); ";
  17.        
  18. mysql_select_db( 'pengunjung' );
  19.  
  20. $retval = mysql_query( $sql, $conn );
  21. if(! $retval )
  22. {
  23.   die('Could not create table: ' . mysql_error());
  24. }
  25. echo "Table created successfully\n";
  26. mysql_close($conn);
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement