Code Monkey home page Code Monkey logo

php-crash-course-2020's Introduction

PHP Crash Course 2020

Initial version - You can download the code and follow the video tutorial.

If you are interested to see final files switch to final-version branch.

The video covers all the basic things about PHP.

  • Comments
  • Variables
  • Numbers
  • Strings
  • Arrays
  • Conditionals
  • Loops
  • Functions
  • Dates
  • Including PHP files
  • Working with File System
  • Object Oriented PHP (OOP)
  • CURL
  • Product CRUD
    • Working with forms
    • File uploading and file validation
    • Working with mysql
  • Composer and autoloading

php-crash-course-2020's People

Contributors

thecodeholic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-crash-course-2020's Issues

I need help to fix this issue

Hello, this is the issue i am getting anytime i tried to submit the form without filling them up. I am trying to submit it empty to validate the errors array and the if statement i made

Fatal error: Uncaught PDOException: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect decimal value: '' for column products_crud.products.price at row 1 in /opt/lampp/htdocs/start/a/14_product_crud/create.php:29 Stack trace: #0 /opt/lampp/htdocs/start/a/14_product_crud/create.php(29): PDOStatement->execute() #1 {main} thrown in /opt/lampp/htdocs/start/a/14_product_crud/create.php on line 29

($callback) must be a valid callback, non-static method

Fatal error: Uncaught TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, non-static method app\controllers\ProductController::index() cannot be called statically in D:\XAMPP\htdocs\php-crash-course-2020-final-version\14_product_crud\03_good\Router.php:53 Stack trace: #0 D:\XAMPP\htdocs\php-crash-course-2020-final-version\14_product_crud\03_good\Router.php(53): call_user_func(Array, Object(app\Router)) #1 D:\XAMPP\htdocs\php-crash-course-2020-final-version\14_product_crud\03_good\public\index.php(20): app\Router->resolve() #2 {main} thrown in D:\XAMPP\htdocs\php-crash-course-2020-final-version\14_product_crud\03_good\Router.php on line 53

"Uncaught PDOException: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect decimal value: '' for column `products_crud`.`products`.`price` at row 1"

If you are a beginner following this tutorial in 3:17:42 after you refresh your server you will encounter this error.

How to bypass this error is to simply declare an if empty statement before the $pdo prepared statement, it should look like this;

if (empty($errors)) {

        $statement = $pdo->prepare("INSERT INTO products (title, image, description, price, create_date)
        VALUES (:title, :image, :description, :price, :date)");
        $statement->bindValue(':title', $title);
        $statement->bindValue(':image', '');
        $statement->bindValue(':description', $description);
        $statement->bindValue(':price', $price);
        $statement->bindValue(':date', $date);
        $statement->execute();
    }

your code should run and you will see the form validation.

PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002] No such file or directory in /opt/lampp/htdocs/product_crud/03_good/Database.php:12

PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002] No such file or directory in /opt/lampp/htdocs/product_crud/03_good/Database.php:12
Stack trace:
#0 /opt/lampp/htdocs/product_crud/03_good/Database.php(12): PDO->__construct()
#1 /opt/lampp/htdocs/product_crud/03_good/Router.php(12): app\Database->__construct()
#2 /opt/lampp/htdocs/product_crud/03_good/public/index.php(8): app\Router->__construct()
#3 {main}
thrown in /opt/lampp/htdocs/product_crud/03_good/Database.php on line 12
[Wed Oct 26 14:05:39 2022] 127.0.0.1:57176 [500]: GET / - Uncaught PDOException: SQLSTATE[HY000] [2002] No such file or directory in /opt/lampp/htdocs/product_crud/03_good/Database.php:12
Stack trace:
#0 /opt/lampp/htdocs/product_crud/03_good/Database.php(12): PDO->__construct()
#1 /opt/lampp/htdocs/product_crud/03_good/Router.php(12): app\Database->__construct()
#2 /opt/lampp/htdocs/product_crud/03_good/public/index.php(8): app\Router->__construct()
#3 {main}
thrown in /opt/lampp/htdocs/product_crud/03_good/Database.php on line 12
[Wed Oct 26 14:05:39 2022] 127.0.0.1:57176 Closing

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.