Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 185636

MySQL is an open-source, relational database management system. If your PHP code uses MySQLi, use the MySQLi tag instead.

7 votes

Is execution of sql in my php code safe?

The correct one for MySQL should be utf8mb4 unless you are using something else. If you use anything else then why? mysqli_real_escape_string does not do what you think it does. …
Dharman's user avatar
  • 881
4 votes

Shoutbox system

Don't mix database logic and display logic (HTML). Prepare the data first and then display it in HTML when you have everything ready. Try to avoid mysqli in new projects. Use PDO whenever possible. I …
Dharman's user avatar
  • 881
4 votes

Adding / updating user info into MySQL database

Here are my ideas. For the insert script I have the same recommendations as @mickmackusa. Stay consistent and use object-oriented syntax for mysqli and prepared statements. You might find it easier to …
Dharman's user avatar
  • 881
5 votes

PDO MySQL queries for web application to reserve a vehicle

You are missing charset in your DSN and you have emulated prepared statements still on. This could potentially leave your vulnerable to SQL injection. See Are PDO prepared statements sufficient to pre …
Dharman's user avatar
  • 881
1 vote

PHP OOP: Configuring MySQL DB & query w/ Twig

You really should use an autoloader. Either Composer autoloader or the PHP built-in one. Your close_db_connection method is useless, you can safely remove it. You have no reason to prematurely close …
Dharman's user avatar
  • 881
5 votes
Accepted

Connect to MYSQL database in PHP with prepared statements

Sam's answer covers a lot of good points I am not going to repeat, but I will tell you more issues. Private properties What is the point in setting constants as private properties? What is the purpose …
Dharman's user avatar
  • 881
3 votes

Functions in PHP to run basic MySQL crud

It's good that you are using prepared statements. That's something that should be a no-brainer and yet it's something people often get wrong. However, there are a lot of weird things in this code. Let …
Dharman's user avatar
  • 881
4 votes

OOP - Contact Form PHP Backend - Procedural to OOP - Dynamic MySQL Prepared Statement PHP

Some main pain points: Never expose MySQL errors to the user! …
Dharman's user avatar
  • 881