Skip to content

Instantly share code, notes, and snippets.

@MN-dev
Last active September 28, 2016 17:06
Show Gist options
  • Save MN-dev/191ac1e84b4f568db7ce213346df5378 to your computer and use it in GitHub Desktop.
Save MN-dev/191ac1e84b4f568db7ce213346df5378 to your computer and use it in GitHub Desktop.
<?php
$host = "localhost";
$user = "root";
$pass = "";
$db = "test";
try{
$conn = new pdo ("mysql:host=$host; dbname=$db",$user,$pass);
}
catch(PDOException $e){
echo "Not connected:" .$e->getMessage();
}
<?php
require 'conn.php';
# exec | querhy | prrpare/execute
# insert / update / delete | select
$title = 'php';
$author = 'zend';
$id = 1;
$conn->exec("update books set title = '$title' , author = '$author' where id = '$id'");
@MN-dev
Copy link
Author

MN-dev commented Sep 28, 2016

-- phpMyAdmin SQL Dump
-- version 4.5.2

-- http://www.phpmyadmin.net

-- Host: localhost
-- Generation Time: Sep 28, 2016 at 05:54 PM
-- Server version: 10.1.16-MariaDB
-- PHP Version: 5.6.24

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";

/!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/
!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS /;
/
!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION /;
/
!40101 SET NAMES utf8mb4 */;

-- Database: test


-- Table structure for table books

CREATE TABLE books (
id int(10) NOT NULL,
title varchar(25) NOT NULL,
author varchar(25) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- Dumping data for table books

INSERT INTO books (id, title, author) VALUES
(1, 'title', 'author');

/!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/
!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS /;
/
!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment