-- phpMyAdmin SQL Dump-- version 4.8.3-- https://www.phpmyadmin.net/---- Host: localhost:3306-- Generation Time: Jan 13, 2020 at 11:24 AM-- Server version: 5.6.41-84.1-- PHP Version: 7.2.7SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT =0;
START TRANSACTION;
SET time_zone = "+00:00";
---- Database: `maconzer_reedoverflow`---- ------------------------------------------------------------ Table structure for table `articles`--CREATETABLE `articles` (
`id` int(11) NOTNULL,
`title` text COLLATE utf8_unicode_ci NOTNULL,
`blurb` text COLLATE utf8_unicode_ci NOTNULL,
`body` text COLLATE utf8_unicode_ci NOTNULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
---- Dumping data for table `articles`--INSERTINTO `articles` (`id`, `title`, `blurb`, `body`) VALUES
(1, 'Testing! 2', 'An article purely for testing the website\'s article-writing service this is the first test, technically.', '# Big Test \r\nYou know we gotta make things work. So that\'s why we do these test things before we actually get to production. I think it\'s nice!!! \r\n\r\n\r\n**And this is bold <3**\r\n\r\n*And this is a list\r\n*and more listing\r\n*And MORE!!!\r\n\r\n### Actually the first\r\n\r\nBut now I\'m updating it. AGAIN\r\n\r\n#### THIRD UPDATE. OR 4? whatever'),
(2, 'Testing!', 'An article purely for testing the website\'s article-writing service', '# Big Test \r\nYou know we gotta make things work. So that\'s why we do these test things before we actually get to production. I think it\'s nice!!! \r\n\r\n\r\n**And this is bold <3**\r\n\r\n*And this is a list\r\n*and more listing\r\n*And MORE!!!'),
(3, 'PHP PDO MySQL Overview', 'Learn how to perform all the SQL queries with PHP\'s PDO class', 'The documentation for PDO is available at [php.net/pdo](http://php.net/pdo) . \r\n\r\n# Create a PDO object\r\nYou may want to use a `try/catch` in case PDO fails to open. \r\n\r\n $pdo = new PDO(\'mysql:dbname=testdb;host=127.0.0.1\', \'dbuser\', \'password\');(\r\n\r\nYou should be able to find the dbname, host, username, and password all in your host\'s server manager page, often cPanel. \r\n\r\nWe\'ll use `$pdo` for the rest of our examples.\r\n\r\n# Query for one item \r\n\r\n $userSearch = $pdo->prepare(\"SELECT * FROM users WHERE user_id =LIKE :user_id AND password_hash LIKE :password_hash\"); \r\n $success = $userSearch->execute(array(\r\n \":user_name\" => $user_name, //assuming you have a user_name variable\r\n \":password_hash\" => $password_hash //also assuming you\'ve prepared this\r\n ));\r\n $userData = $userSearch->fetch();\r\n $userSearch->closeCursor();\r\n\r\nNext, we will cover checking your results for what you want.\r\n\r\n# Validating your results\r\nSee `$userData = $userSearch->fetch();` under **Query...* above.\r\n\r\nWe\'ll edit that line to\r\n if ($success===FALSE){\r\n //print an error, or throw an Exception\r\n return;\r\n } else if ($userSearch->rowCount()===0) {\r\n //print error for no results, throw exception, or alternate\r\n return;\r\n } else if ($userSearch->rowCount()>1) {\r\n //throw/print a different error, as there should only be one matching user row\r\n return;\r\n }\r\n $userData = $userSearch->fetch(); \r\n\r\nYou can have an else block for that last line, instead of using those returns. However, I like to do it this way so my success code block is not contained within a giant `if`, which I find ugly and distracting.\r\n \r\n');
-- ------------------------------------------------------------ Table structure for table `auth`--CREATETABLE `auth` (
`id` int(11) NOTNULL,
`user_id` int(11) NOTNULL,
`name` text COLLATE utf8_unicode_ci NOTNULL,
`data` text COLLATE utf8_unicode_ci NOTNULL,
`expiresAt` int(11) NOTNULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
---- Dumping data for table `auth`--INSERTINTO `auth` (`id`, `user_id`, `name`, `data`, `expiresAt`) VALUES
(3, 2, 'cookie', '%242y%2410%24gLIheA2x5D7cQJRkNY7J%2FexhRPKQzGmMfCAs1WIWtETL5OBH.Dh5G', 1549844705),
(5, 2, 'cookie', '%242y%2410%24W.NJIjfhq9mGmW0TCGVM0.pc1OaBssT6NZjDoNq3hF29I0DgY6kBS', 1549844724),
(6, 2, 'cookie', '%242y%2410%24CfGeDzrVNAmR4ud0Ysry7eSp4RvzV8sqr4CCLUvcI1ORBrG3BQPRq', 1549845006);
-- ------------------------------------------------------------ Table structure for table `info`--CREATETABLE `info` (
`id` int(11) NOTNULL,
`name` text COLLATE utf8_unicode_ci NOTNULL,
`email` text COLLATE utf8_unicode_ci NOTNULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
---- Dumping data for table `info`--INSERTINTO `info` (`id`, `name`, `email`) VALUES
(2, 'Reed Sutman', 'rsutman@gmail.com');
-- ------------------------------------------------------------ Table structure for table `permissions`--CREATETABLE `permissions` (
`id` int(11) NOTNULL,
`user_id` int(11) NOTNULL,
`access_level` int(11) NOTNULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
---- Dumping data for table `permissions`--INSERTINTO `permissions` (`id`, `user_id`, `access_level`) VALUES
(1, 2, 20001);
-- ------------------------------------------------------------ Table structure for table `rof_articles`--CREATETABLE `rof_articles` (
`id` int(11) NOTNULL,
`title` text COLLATE utf8_unicode_ci NOTNULL,
`url` text COLLATE utf8_unicode_ci,
`blurb` text COLLATE utf8_unicode_ci NOTNULL,
`body` text COLLATE utf8_unicode_ci NOTNULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
---- Dumping data for table `rof_articles`--INSERTINTO `rof_articles` (`id`, `title`, `url`, `blurb`, `body`) VALUES
(1, 'Fixing PHP Recoverable Fatal Error: Object of class Closure could not be converted to string in ...', 'closure-string-error', 'See how to fix Recoverable the Fatal Error: Object of class Closure could not be converted to string in ... You\'re converting to a string, when you need to invoke the function. ', 'Let\'s suppose you have a `closure` (which is an inline `function`) assigned to a variable, such as:\r\n\r\n```php\r\n<?php\r\n //Enter your code here, enjoy!\r\n\r\n//this is pseudo-random and NOT cryptographically secure\r\n$randomChars = function($length)\r\n{\r\n for (\r\n $chars = array(\'0123456789\',\'abcdefghijklmnopqrstuvwxyz\',\'ABCDEFGHIJKLMNOPQRSTUVWXYZ\',\'!@#$%^&*()_+-=\'),\r\n $randomString=\"\",\r\n $i=0;\r\n $i<$length;$i++){\r\n $randomString .= \r\n substr($chars[$i%4], \r\n random_int(0, strlen($chars[$i%4])), 1);\r\n }\r\n return $randomString;\r\n};\r\n\r\n?>\r\n\r\n```\r\nThis is a fairly simple random string generator. \r\n\r\nNow, let\'s suppose you\'re getting the error **Recoverable Fatal Error: Object of class Closure could not be converted to string in** and you\'re stuck.\r\n\r\nYou probably have a bit of code like:\r\n```php\r\necho \"Here are my random characters: \".$randomChars;\r\n```\r\nWell, this generates an error, because `$randomChars` isnot a string. It is a `function` which *returns* a string. \r\n\r\n## The Fix\r\nInstead ofusing `$randomChars` as a string, use it as a function:\r\n```php\r\n$theChars = $randomChars(15); //get a random string 15 characters long\r\necho \"I have this random string: \".$theChars;\r\n```\r\nNow everything works, because you\'re getting the return value of the function call, rather than trying to print out the function itself.');
---- Indexes for dumped tables------ Indexes for table `articles`--ALTERTABLE `articles`
ADDPRIMARYKEY (`id`);
---- Indexes for table `auth`--ALTERTABLE `auth`
ADDPRIMARYKEY (`id`);
---- Indexes for table `info`--ALTERTABLE `info`
ADDPRIMARYKEY (`id`);
---- Indexes for table `permissions`--ALTERTABLE `permissions`
ADDPRIMARYKEY (`id`),
ADDUNIQUE KEY `user_id` (`user_id`);
---- Indexes for table `rof_articles`--ALTERTABLE `rof_articles`
ADDPRIMARYKEY (`id`),
ADDUNIQUE KEY `url` (`url`(254));
---- AUTO_INCREMENT for dumped tables------ AUTO_INCREMENT for table `articles`--ALTERTABLE `articles`
MODIFY `id` int(11) NOTNULL AUTO_INCREMENT, AUTO_INCREMENT=4;
---- AUTO_INCREMENT for table `auth`--ALTERTABLE `auth`
MODIFY `id` int(11) NOTNULL AUTO_INCREMENT, AUTO_INCREMENT=7;
---- AUTO_INCREMENT for table `info`--ALTERTABLE `info`
MODIFY `id` int(11) NOTNULL AUTO_INCREMENT, AUTO_INCREMENT=3;
---- AUTO_INCREMENT for table `permissions`--ALTERTABLE `permissions`
MODIFY `id` int(11) NOTNULL AUTO_INCREMENT, AUTO_INCREMENT=2;
---- AUTO_INCREMENT for table `rof_articles`--ALTERTABLE `rof_articles`
MODIFY `id` int(11) NOTNULL AUTO_INCREMENT, AUTO_INCREMENT=2;
COMMIT;