Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class connection {
- /*** mysql hostname ***/
- protected $hostname = 'localhost';
- /*** mysql username ***/
- protected $username = 'root';
- /*** mysql password ***/
- protected $password = '';
- public $dbc;
- public function __construct(){
- try {
- $this->dbc = new PDO("mysql:host={$this->hostname};dbname=test", $this->username, $this->password);
- /*** echo a message saying we have connected ***/
- echo"تم الإتصال بنجاح .";
- }
- catch(PDOException $e)
- {
- echo $e->getMessage();
- }
- }
- public function insert($table,$rows,$values){
- try {
- return $this->dbc->exec("INSERT INTO ".$table."(".$rows.") VALUES ('".$values."')");
- }
- catch(PDOException $ie)
- {
- echo $ie->getMessage();
- }
- }
- }
- $connection = new connection();
- $connection->insert("tbl", "name", "'star'");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement