Advertisement
Guest User

Untitled

a guest
Feb 5th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.50 KB | None | 0 0
  1. <?php
  2.  
  3. class sql {
  4.     function __construct() {
  5.         $host="localhost";
  6.         $user="k963767g_sql";
  7.         $pass="hackerman951";
  8.         $db_name="k963767g_sql";
  9.         $link=mysql_connect($host,$user,$pass);
  10.         mysql_select_db($db_name,$link);
  11.     }
  12.  
  13.  
  14.     function write($date, $author, $author_url, $author_image, $post_url, $text, $image, $price, $headline, $post_image)
  15.     {
  16.         $sql = mysql_query("INSERT INTO `Base`(`date`, `author`, `author_url`, `author_image`, `post_url`, `text`, `image`, `price`, `headline`, `post_image`) VALUES ('".$date."','".$author."','".$author_url."','".$author_image."','".$post_url."','".$text."','".$image."','".$price."','".$headline."','".$post_image."')");
  17.     }
  18.  
  19.     function get_user_login_and_passwrd()
  20.     {
  21.         $sql = mysql_query("SELECT * FROM `login`") or die("Base error");
  22.  
  23.         $row = mysql_fetch_array($sql);
  24.         return array($row['login'], $row['password']);
  25.     }
  26.  
  27.  
  28.  
  29.     function get_url()
  30.     {
  31.         $sql = mysql_query("SELECT * FROM `URL`") or die("Base error");
  32.         $list_url = array();
  33.         while($row = mysql_fetch_array($sql))
  34.         {
  35.             array_push($list_url, $row['URL']);
  36.         }
  37.         return $list_url;
  38.     }
  39. }
  40.  
  41. $class = new sql();
  42. $class->write("2019-02-05", "Name_author", "https://vk.com/autor_url", "https://vk.com/image_autor", "https://vk.com/wall_123", "We sell a house with a discount", "IMAGE", "566", "HEADLINE", "imAGE_pOST");
  43.  
  44. $a = $class->get_url();
  45. echo $a[0];
  46.  
  47. $a = $class->get_user_login_and_passwrd();
  48. echo $a[0]; //Login
  49. echo $a[1]; //Password
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement