Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Database
- {
- function Database($servername, $username, $password, $dbname)
- {
- $this->servername = $servername;
- $this->username = $username;
- $this->password = $password;
- $this->dbname = $dbname;
- }
- function connect()
- {
- $con = mysql_connect($this->servername, $this->username, $this->password);
- if (!$con)
- {
- die('Could not connect: ' . mysql_error());
- }
- mysql_select_db($this->dbname, $con) or die ('Could not select db');
- return true;
- }
- function query($query)
- {
- $result = mysql_query($query) or die('Could not execute the query: '.$query.' <br/>Error:' . mysql_error( ) );
- return $result;
- }
- function protect($variable)
- {
- $var2 = $variable;
- $var2 = htmlspecialchars(mysql_real_escape_string($var2));
- return $var2;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement