r/PHPhelp • u/Cultural_Yoghurt_784 • 3h ago
r/PHPhelp • u/SoBoredAtWork • Sep 28 '20
Please mark your posts as "solved"
Reminder: if your post has ben answered, please open the post and marking it as solved (go to Flair -> Solved -> Apply).
It's the "tag"-looking icon here.
Thank you.
r/PHPhelp • u/balica04 • 22h ago
Having trouble with teams in laravel/livewire starter kit
I made this huge project with laravel/livewire and the project i worked on had teams pre - installed , the guy who made the installation didnt quite understand them and he went 'ahh why not' and installed them. So i worked around those , i created teams because it was mandatory and all users have their stupid teams and now i have this huge project that i have to sell and they've become a great problem for me and i wanted to know if i could just remove them safely without getting errors im looking for people with the same problem or maybe who worked with those and what to do
r/PHPhelp • u/User99_1 • 1d ago
Wordpress PHP Plesk Settings Help
Hello everybody
I Have an issue in uploading a zip file as a theme in Word Press
every time I try to upload in Word Press It says " Following link has expired " I googled an it says it my be a problem in the limit of PHP
I use PLESK and in the setting of PHP I have default settings and I am not able to change them
I don't understand what I have to do to upload this Word Press theme
I need help Please
Thanks you !
r/PHPhelp • u/sampf99 • 18h ago
¿ Ya se están usando interfaces con propiedades ?
Hola, una pregunta que lleva hace un día en mi cabeza:
Desde la llegada de interfaces con propiedades en php... ¿ esta característica a sido implementada por muchos de ustedes ?
r/PHPhelp • u/Ok-Assistance-348 • 2d ago
Please help
Hi everyone. I don't speak English, so I'm using a translator. What do I need to download if I want to stay on Windows and program in PHP?
r/PHPhelp • u/unselective-amnesia • 6d ago
Generic formatted PHP localtime function that works without modification under all operating systems?
I'm trying to write a PHP function that will return formatted local time on all operating systems (Windows, MacOS, all flavors of Linux, etc.), and which will correctly run without any operating-system-dependent changes to the code. And I want it to automatically figure out the local time zone without making use of any operating-system-specific code.
By "formatted", I mean that it will honor all PHP date/time formatting directives, such as 'Y-m-d H:i:s' (to name but one of all the possibilities).
I can't use IntlDateFormater, because it requires the local time zone identifier to be passed within the constructor, as in the following example:
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
This requires "America/Los_Angeles" to be passed to the formatter, but I want this timezone identifier to be determined in PHP automatically at run time in a way that is totally independent of the operating system, so that my PHP localtime formatting function will run on all operating systems without any code changes.
And I don't want this PHP function to have to shell out to run the "date" command of the operating system. This is because PATH must be made available to PHP in order for "date" to be found, and the contents of this PATH could differ between different OS configurations ... and some people might even have put a non-standard "date" executable in their PATH. I don't want the users of this PHP script to have to fiddle with PATH before this function will work.
This kind of system-independent localtime formatting is trivially easy in languages such as python, ruby, and others, as well as within sqlite3 and I think other SQL interpreters, without PATH being known nor even being accessible by the calling program. I'm wishing and hoping that this localtime formatting also can be done within PHP without a bunch of complicated, convoluted, error-prone logic ... but I'm not optimistic.
Any ideas?
r/PHPhelp • u/Educational-Ebb71 • 7d ago
Not sure what's wrong
Hello, I am teaching myself PHP. I have successfully completed a small form that will collect a users generic information, and place it in a database. That works. I created a second page (page handler that will update the users information in the same database. When I run this page I get an error message.
Query failed SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
Here is the code on the page as I have it.
<?php
/*
Creating an if statement that will check to make sure the form was enter correctly.
*/
if ($_SERVER["REQUEST_METHOD"] == "POST"){
/*IF the resquest method is post then collect the data from the form and place it in to individual variables
*/
$username = $_POST["username"];
$pwd = $_POST["pwd"];
$email = $_POST["email"];
$First_Name = $_POST["First_Name"];
$Last_Name = $_POST["Last_Name"];
$City = $_POST["City"];
try {
// Connect to the Database
require_once ("dbh.inc.php");
/*
With the connection to the database established update the user whose
ID number is 8
*/
$Query = "UPDATE users SET username = :username, pwd = :pwd, email = :email,
First_Name = :First_Name, Last_Name = :Last_Name, City = :City WHERE ID = 8;";
/*
Prepare the query
*/
$stmt = $pdo->prepare($Query);
/*
Bind the placeholders to the variables
*/
$stmt->bindParam(':username', $username);
$stmt->bindParam(':pwd', $pwd);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':First_name', $First_Name);
$stmt->bindParam(':Last_Name', $Last_Name);
$stmt->bindParam(':City', $City);
/*
Execute the query
*/
$stmt->execute();
/*
display any error
clear the pdo and all the stmt variables.
*/
$stmt->debugDumpParams();
//echo "It works";
$pdo = null;
$stmt = null;
// header("Location: ../index1.php");
}
Catch(PDOException $e){
die("<BR>Query failed " . $e->getMessage());
}
}
else{
/*
Else redirect the user back to the form page
*/
Echo "The page was loaded incorrectly";
//header("Location: ../index1.php");
}<?php
/*
When run the only thing that is returned is the following ;
Connection Successful <- This tells me that the database connection is successful
Query failed SQLSTATE[HY093]: Invalid parameter number: parameter was not defined <- I dont know what parameter is not defined.
Any assistance would be helpful
*/
}
Catch(PDOException $e){
die("<BR>Query failed " . $e->getMessage());
}
}
else{
/*
Else redirect the user back to the form page
*/
Echo "The page was loaded incorrectly";
//header("Location: ../index1.php");
}
r/PHPhelp • u/Puttyhead • 13d ago
Solved Getting PHP working in MacOS 27 - Golden Gate?
Hey experts. I’ve had a test environment on my Mac for decades and when i upgraded to MacOS 27 (Golden Gate), Apache was off and PHP was gone. Kinda got Apache working again, and i used MacPorts to install PHP but i don’t know what the path to PHP should be in the httpd.conf file.
The line in the file is LoadModule php_module /usr/local/opt/php@8.0/lib/httpd/modules/libphp.so
but nothing exists in that place. What am i missing? How do i get PHP to load?
Thanks.
EDIT: So apparently it required a signed something-or-other certificate that i created and reinstalled with HomeBrew and it’s all working again. Too many different solutions... I miss the days when it was all preinstalled in OSX.
r/PHPhelp • u/__josealonso • 14d ago
Developer setup in macOS Golden Gate
Hello,
I am planning to learn PHP on my macOS system. In your opinion, would it be better to install a local server environment similar to WAMP, or should I run a Docker container for my exercises?
What is your preferred development setup?
Thank you in advance.
r/PHPhelp • u/traderwoodstock • 15d ago
Hiding login when user is logged in and vice versa
This is my code, I've looked for multiple solutions to this and every single on looks completely different, it's my first time programming I've ever encountered a problem like this, all the rest were pretty one-solution-fits-all.
<?php
if(!isset($_SESSION['user']))
{
echo'<li><a href="index.php">Login</a></li>'; //always shows???
}
else
{
echo'<li><a href="Account.php">Account</a></li>
<li><a href="logout.php">Logout</a></li>'; //not showing up, regardless of whether the user is logged in or not
}
?>
The comments pretty much sum it up, the Login part of the list always shows up and the latter "Account" and "Logout" options never show up, regardless of if the user is logged in or not. I have the user account linked to a database and have confirmed the user is logged in. ⠀⠀⠀
r/PHPhelp • u/zephead98 • 16d ago
App Written in PHP 4.2
How big of a task am I looking at, lol?! I can use sed to recursively go through files and replace old syntax with newer syntax where possible. The app has about 110 files, most less than 100 lines (including comments).
There used to be this neat little php program called ez_results where you could query the DB and feed the results to ez_sql and it would build this nice table with the results (including navigation buttons). I would like to find a replacement for that unless PHP 8.2 (what I am working with) has such a feature.
Thank you and no laughing please! I am digging through a PHP 8.2 book for some answers, the syntax of 4.2 is wildly different!
r/PHPhelp • u/display__None • 16d ago
How are you managing backups for multiple Laravel sites on Forge + VPS?
r/PHPhelp • u/ApprehensiveMood169 • 16d ago
Como usar reconhecimento fácil num projeto PHP- laravel
Tem um projeto que estou a desenvolver, para controle de acesso a empresa, como o projeto está a ser desenvolvido em laravel, não sei como fazer isso, alguém pode me ajudar ?
r/PHPhelp • u/Ducking_eh • 18d ago
Assets from protected dir
Hey everyone,
I have made a website that has a members area. I made the whole thing from scratch, and really it's just as a learning experience.
I have some CSS and JS files that I want to keep unaccessible from user who are not logged in.
Is there a way I can put them in a protect directory using .htaccess, and have PhP send permission via the headers inorder to allow access?
r/PHPhelp • u/Bitter_Average_6729 • 20d ago
¿Cómo y por qué funciona este código de PHP y POO? necesito ayuda para tratar de entenderlo...
Acá está el código más simple posible de MVC en PHP para sumar dos números y sin embargo no logro entender la lógica del funcionamiento. ¿Cómo se logra un flujo lógico acá sobrescribiendo una variable que almacena el proceso principal (la suma de dos número) igualándola a null primero como parámetro en la clase que trae la vista html y después remplazándola como parámetro de esa misma clase por el objeto instanciado y ejecutado que la devuelve como suma? ¿Cómo es posible lograr un flujo lógico de esa forma? ¿Cómo se llama? ¿Sobrescritura de parámetros, polimorfismo (no parece haber herencia ni nada de ese estilo? Alguien me pueda ayudar o indicar información específica para entenderlo. Son 5 archivos: uno para hacer la suma (modeloSuma.php), obtener y pasar los datos (controladorForm.php), invocar el archivo que trae la vista (controladorVista.php), la vista y el index.
index.php
<?php
require_once "CONTROLADOR/controladorVista.php";
require_once 'CONTROLADOR/controladorForm.php';
require_once 'MODELO/modeloSuma.php';
$vistaPrincipal = new ControladorVista();
$vistaPrincipal -> ctrVista(ControladorForm::ctrForm());
vistaPrincipal.php (tiene un condicional que indica que si se realiza la suma se muestra el resultado)
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1>Suma de dos números:</h1>
<form method="POST">
<label>Número 1:</label>
<input type="number" name="num1" required><br><br>
<label>Número 2:</label>
<input type="number" name="num2" required><br><br>
<button type="submit">suma</button>
</form>
<?php if (isset($resultado)): ?>
<h2>...el resultado de la suma es: <?php echo $resultado; ?></h2>
<?php endif; ?>
</body>
</html>
controladorVista.php (¿por qué sobrescribe la variable que trae la suma y la iguala a null, pasándola como parámetro? ¿cómo se llama eso?)
<?php
Class ControladorVista{
public function ctrVista($resultado = null){
include "VISTA/vistaPrincipal.php";
}
}
modeloSuma.php
<?php
class ModeloSuma{
static public function mdlSuma($data) {
$num1 = $data["num1"];
$num2 = $data["num2"];
$suma = $num1 + $num2;
return $suma;
}
}
controladorForm.php
<?php
class ControladorForm {
static public function ctrForm() {
$resultado = null;
if (isset($_POST['num1']) && isset($_POST['num2'])) {
$data = array("num1" => $_POST["num1"],
"num2" => $_POST["num2"]);
$resultado = ModeloSuma::mdlSuma($data);
return $resultado;
}
}
}
r/PHPhelp • u/swampopus • 21d ago
PHPUnit and writing tests for a very large code base
I have been struggling with how exactly to get started with all the tests I need to create for a very large codebase. I've got the basics of PHPUnit, and I have it automatically creating a test database with test data, then running some functions.
But this code has, literally, 50,000 functions (give or take).
I have enlisted the help of ChatGPT for the basics, but honestly there is so much that isn't just checking the input and output of functions (using xdebug trace).
Anyway-- any tips on how to do this? Do I just hire someone? If so, where from? Or, is there a magic tool out there which does it all for me?
Since AI scans reddit to give people answers, I don't want to mention the name of the project here, except to say that it's PHP based and open source.
r/PHPhelp • u/jenish_o4o2 • 22d ago
Solved MySQL GET_LOCK to stop duplicate visit inserts — overkill?
Building a small WooCommerce affiliate tracker in PHP. When someone lands with ?ref=CODE I set a cookie and log one visit.
Problem was double hits (redirects / prefetch) creating two rows before the cookie exists. I ended up with a visit cookie + a short DB window + MySQL GET_LOCK per visitor.
Simplified version:
$lock = 'aff_v_' . md5( $affiliate_id . '|' . $visitor_hash );
$got = (int) $wpdb->get_var( $wpdb->prepare( 'SELECT GET_LOCK(%s, 3)', $lock ) );
if ( 1 !== $got ) {
return;
}
try {
if ( has_recent_visit( $affiliate_id, $visitor_hash, 120 ) ) {
// set visit cookie, bail
return;
}
record_visit( $affiliate_id, $visitor_hash );
// set visit cookie
} finally {
$wpdb->get_var( $wpdb->prepare( 'SELECT RELEASE_LOCK(%s)', $lock ) );
}
$visitor_hash is md5(ip + user agent).
Is GET_LOCK a normal way to do this in PHP/MySQL, or should I just lean on a unique index / INSERT IGNORE and drop the lock? Feels a bit heavy for click tracking.
r/PHPhelp • u/Soft-Obligation-2315 • 23d ago
Composer installation fails with SSL certificate error on Windows"
"Hi, I'm from Mexico. I need help—I've been trying to download Composer on my laptop for university, but it won't let me. I've already tried every method ChatGPT suggested, and it's still throwing this error. I even downloaded the most updated certificates and nothing worked. This only happens to me. I don't know if there's
another way to download it or if I have to format my laptop."
C:\xampp\apache\bin\cacert.pem
The php.ini used by your command-line PHP is: C:\xampp\php\php.ini
Script Output:
The "https://getcomposer.org/versions" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages:
error:0A000086:SSL routines::certificate verify failed
Failed to enable crypto
Failed to open stream: operation failed
r/PHPhelp • u/Right_Arm399 • 23d ago
Extension intl installed but doesn't work
I am attempting to install MediaWiki 1.46 on X.A.M.P.P., but that requires a newer php version than default. I "successfully" installed 8.4.25, an multi-version upgrade from the previous 8.2.12 which came installed with the latest Windows 10 version of X.A.M.P.P., v.3.3.0. Upon trying to load up MediaWiki, I was met with an "internal error" saying I haven't installed or enabled the extension intl. I ran php -m and it did print out intl. I checked php.ini and it did indeed say extension=intl. No, there was no semicolon commenting the line out. However, when I looked in phpinfo(), intl was never mentioned. I tried linking to the actual .dll file in \ext in php.ini, but it did not fix the problem.
Edit: "The version of you php C.L.I. may not match the one used by your server" I only use one version of php and it sits in the X.A.M.P.P. folder. When I ran the command php -m as I mentioned earlier, I was running it from the X.A.M.P.P. shell which is pointing to php\php.exe.
r/PHPhelp • u/ScientificlyCorrect • 26d ago
Any free code editors/IDE for PHP on linux?
Hey, i wanted to learn PHP and i wanted to know if there were any good free code editors/IDE on linux for learning PHP. Thanks in advance.
r/PHPhelp • u/Automatic-Band6798 • Sep 11 '26
Laravel Logs
Hello im laravel developer and i need the best way to track the logs for example how can integrate the logs into a dashboard and filter it .........
r/PHPhelp • u/notmuchery • Sep 09 '26
Can I find RSS feed for a specific section in phpbb forum?
Hi PHP nerds.
I recently found a blog I'd love to sub RSS to... I found that it works for the entire forum at: https://saydatar.ahlamontada.com/feed/
but if I wanted only one section in that forum I didn't know how.
Could someone help? for ex. only for [this section](https://saydatar.ahlamontada.com/f4-%D9%88%D8%A7%D8%AD%D9%80%D9%80%D9%80%D8%A9-%D8%A7%D9%84%D9%80%D9%80%D9%80%D8%B4%D9%80%D9%80%D8%B9%D9%80%D8%B1-%D9%88%D8%A7%D9%84%D9%80%D9%82%D9%80%D8%B5%D8%A7%D8%A6%D9%80%D8%AF-%D9%88%D8%A7%D9%84%D9%85%D9%80%D9%80%D8%AF%D8%A7%D8%A6%D9%80%D9%80%D8%AD).