22,553 questions
Advice
1
vote
10
replies
170
views
I would like to get some advice on this sql connenction with php. We use this in our school. Can you guys help if there is a better way to do it?
So this is the connection file. This is what we are using but my classmate said its not the best and not the safest but i want to use the structure of it.
<?php
function getData($muvelet, $...
Best practices
1
vote
10
replies
211
views
Why does the first insert method work, not another one?
I need to use insert method that prevent again injection attacks.
Need to understand the why and to learn also.
When I use these code its works PERFECTLY:
<form action="my_insert_method" ...
Best practices
0
votes
7
replies
147
views
Simple SQL (Get and Edit Data)
<?php
// get data or modify data
function getData($sql){
$db = new mysqli("localhost", "root", "", "database");
if($db->...
Best practices
2
votes
15
replies
310
views
Does my code look secure? And How do I prevent people from entering a page?
To practice php I created a login system that only works for 1 user, and if you type in the wrong username/password it will kick you out. If you type the right one it sends you to a devtools.php. I'm ...
1
vote
1
answer
150
views
How do I get a CSV file uploaded via an HMTL form to import using mysqli_query? [duplicate]
I read this Q&A PHP MySQL LOAD DATA INFILE from CSV File Upload and others on how to use mysqli_query and LOAD DATA LOCAL INFILE.
But I can't find any details on how the HTML form is actually used ...
Advice
2
votes
3
replies
257
views
I don't understand this piece of PHP connect database code
I started learning PHP a few days ago and I am currently learning rest api. I tried asking gpt about it but I could not understand it.
<?php
function adatokLekerdezese($muvelet ){
$db = ...
Best practices
1
vote
7
replies
160
views
PHP arrays or SQL query in loop?
Which code is preferred and why?
Using a query in a loop, but with id search, so it should be quick.
$pray_res = sql_query($conn, "SELECT * FROM prayer_stats ORDER BY year DESC, month DESC"...
0
votes
0
answers
77
views
MYSQLi Vulnerabilities with Prepare statement and order by [duplicate]
I've done a little looking around on string statements for MYSQLi and changed to prepared statements because of injection vulnerabilities. That has been all fine until now. I now need to use order by ...
3
votes
0
answers
99
views
compiling PHP 8.* with libmysqlclient for MySQL 8.* w/o resorting to the disabled by default in MySQL 8.4/removed in MySQL 9 mysql_native_password [duplicate]
In MySQL I have created the user in this webpage query using the query:
CREATE USER '[user]'@'[host]' IDENTIFIED WITH caching_sha2_password BY '[password]';
and granted this user the only permissions ...
0
votes
0
answers
52
views
Escaping strings using mysqli without passing a connection parameter in PHP to function [duplicate]
I am updating some legacy PHP code that makes use of mysql_escape_string to escape strings. The web host has not included the PDO module in their latest upgrade (I have spent hours in pointless chat ...
-3
votes
2
answers
116
views
Update database table where array value is not equal to
I am using the PHP SimpleMysqli wrapper class to update a database. I want to use a "value is not equal to" in the where clause.
Current code updates where 'id' = $id, I want where 'id' != $...
4
votes
1
answer
135
views
CI4 + PHP 8.1: Finally block not executed when mysqli_sql_exception occurs (but works with register_shutdown_function)
I'm working on a CodeIgniter 4 project (CI: 4.4.3 production mode | PHP: 8.1.32), and I'm running into a strange issue where my finally block never executes if a database error happens during ...
-4
votes
1
answer
104
views
What is meant by "This function does nothing unless OpenSSL support is enabled"?
The PHP manual entry for mysqli_ssl_set() says:
Used for establishing secure connections using SSL. It must be called before mysqli_real_connect(). This function does nothing unless OpenSSL support ...
0
votes
0
answers
24
views
php pcntl_fork causes mysqli errors [duplicate]
I am trying to add process control to my working code. I added it to a part of my code that reads in the database and loops through that. The original code works fine. After adding pcntl code, a mysql ...
1
vote
0
answers
83
views
Is this code already SQL injection proof or should I use prepared statements? [duplicate]
I was asked to make this code SQL Injection proof:
<?php
$connection = mysqli_connect("localhost", "root", "password", "users_db");
$query = "SELECT * ...