Guide 04 / 4
Resources and review
Learn to consult documentation, solve an error and check what you have learned.
Find reliable information and explain what you have built.
01 · Reading the PHP references
The official links appear under the guide.
PDO manual · The connection and the results
Read the introduction to PDO and the pages on the constructor, fetch and fetchAll. Check the return types and the FETCH_ASSOC mode.
Example
Mission : expliquer pourquoi la liste utilise fetchAll et la fiche fetch.
PDO manual · Prepared queries
Spot the separation between SQL text and values, and the limits of named parameters. Redo the recipe page with another identifier.
Example
Mission : expliquer pourquoi ORDER BY :colonne ne sert pas à choisir un nom de colonne.
PHP manual · Sessions and hash_equals
Explore keeping a token in a session and comparing it. Observe the session cookie of your own project in the browser tools.
Example
Mission : retrouver où le jeton est créé, envoyé et contrôlé dans ajouter.php.
02 · Troubleshooting and validating the complete path
Tell a connection, SQL, data or display problem apart.
could not find driver or connection impossible
Check pdo_mysql, the MySQL server, the host, the port, the terminal variables and the account's privileges. Restart the PHP server after changing its configuration.
Example
php -m
mysql -h 127.0.0.1 -u blog_app -p blog_recettes
Testing the same account and host in the SQL client helps isolate the problem.
Unknown column, missing parameter or expired form
Unknown column points to the schema; compare the names with schema.sql. A missing parameter points to prepare/execute. An invalid token requires reloading the form and checking that cookies are accepted.
Example
Colonnes attendues : titre, duree_minutes, portions, ingredients, etapes, categorie_id.
Éviter les sorties avant session_start ou header.
Final self-assessment · Explain the whole chain
Describe a recipe's journey from the form to MySQL and then to the displayed HTML. Reproduce a valid add, an invalid-duration rejection, a search and a 404 recipe page.
Example
Je sais :
□ configurer PDO ;
□ préparer et lier une requête ;
□ distinguer fetch et fetchAll ;
□ valider avant INSERT ;
□ échapper à l’affichage ;
□ vérifier le jeton puis rediriger ;
□ constater la persistance.
Extensions after consolidation: pagination, authentication and authorisations, modification and deletion via POST, then a detailed model of the ingredients.