forked from rukshn/helius
-
Notifications
You must be signed in to change notification settings - Fork 1
/
db.php
59 lines (50 loc) · 1.46 KB
/
db.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
// Make a MySQL Connection
$db_user = "USERNAME";
$db_pass = "PASSWORD";
$db_name = "DATABASENAME";
mysql_connect("localhost", $db_user, $db_pass) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());
// Create users table
mysql_query("CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`userid` int(11) NOT NULL,
`propic` text,
`token` text,
`twitter_token` text NOT NULL,
`twitter_secret` text NOT NULL,
PRIMARY KEY (`id`)
)")
or die(mysql_error());
//Create post table
mysql_query("CREATE TABLE `posts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`postid` varchar(20) NOT NULL,
`link` text NOT NULL,
`tagline` varchar(200) NOT NULL,
`title` varchar(200) NOT NULL,
`user` varchar(30) NOT NULL,
`post_time` varchar(30) NOT NULL,
PRIMARY KEY (`id`)
)") or die (mysql_error());
//create vote table
mysql_query("CREATE TABLE `votes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`post_id` varchar(20) NOT NULL,
`user_id` varchar(30) NOT NULL,
`op_id` varchar(30) NOT NULL,
PRIMARY KEY (`id`)
)")
or die(mysql_error());
//create comment table
mysql_query("CREATE TABLE `comments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`comment` text NOT NULL,
`user_id` varchar(30) NOT NULL,
`post_id` varchar(20) NOT NULL,
`commentid` varchar(20) NOT NULL,
`ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
)") or die(mysql_error());
?>