For several days I have been trying to install PHP. It is version 8.1.2. I download the zip file from www.php.net. Unpack the zip file to where I want it, and open the php folder. No matter which .exe file I click to open, the installation will not start. The closest I get to the installation will start is that if I click on php.exe, a window will pop up for a few seconds, then it will be just as quiet. What am I doing wrong?
PHP dont Start.
- Edited
Unpacking the zip file is installation. You've already moved the folder to somewhere convenient, so you're basically done already.
When you double-click on it, php.exe starts, runs the script you gave it, and then shuts down again. But because you didn't give it a script it shut down immediately because it had nothing to do.
Now that you've got PHP installed, there are different things you can do depending on how you want to use it. Using it in a web server involves setting up the web server to use the .exe files you have unpacked; how that's done depends on the web server you've chosen.
Otherwise, you'll be running it from the command line. If you're doing that I suggest you add php.exe's location to your Windows PATH so you don't have to be typing the full pathname every time. You'd then run a script by typing php -r script-name.php
.
If you're looking for a command (so-called REPL) environment that you want to sit at and type PHP into and have it run the commands as you type them, start it as php -a
.
The PHP documentation also offers some helpful information:
On Windows platforms, it's possible to associate php.exe with the double click option of the .php extension, or a batch file can be created to run scripts through PHP.
There's also a page on Command Line PHP on Microsoft Windows.
Thanks, both of you. Does any of you know what version of PHP I need for my Laragon 5.0.0 installation on my Windows 11 OS? I am confused over the threaded or unthreaded version. What is right? There are as many suggestions and tips as users on the internet.
- Edited
That depends on your choice of web server. Thread safe would be safer, and it's what I use even for shell scripting (even though the installation instructions recommend non-thread-safe in that case). The performance hit isn't yet big enough for me to be worrying about. There: now you have another user with another suggestion.
According to https://laragon.org/download/ Laragon Full comes with PHP 7.4 already as part of it.
Thanks. I installed it one more time. Then i Got it with 7.4X. I guess I had an old version. Strange, but the only explanation. And after that, I could have PHP 8.1.2 . So now everything is perfect and working. Except for the Visual Studio Code. Something is very strange there too.... I'll look at it later.
I'm having a problem with starting a session in PHP. By looking around I wrote some code that should work but it doesn't. Can you please help me out because I don't know what's wrong here? This is my loging.php page
<?php
$host = "localhost";
$user = "usern";
$password = "gtest123";
$db = "test";
$errore = "Login info are wrong!enter code here
";
mysql_connect($host,$user,$password);
mysql_select_db($db);
if(isset($_POST['username'])){
$username = $_POST['username'];
$password = $_POST['password'];
$sql = "select * from utenti where username = '".$username."' AND Password = '".$password."' limit 1";
$result = mysql_query($sql);
Basically, on depending this I have developed erp systems and related things.
if(mysql_num_rows($result)==1){
$_SESSION['username'] = $username;
header("location:index.php");
}
else{
echo "" .$errore;
}`enter code here`
}
?>
I than have my db with users on phpmyamin and the login it's working. The problem is when I load the index.php page.
<?php
session_start();
echo "Welcome" .$_SESSION[''];
?>
<html>
all the html code
I start this session because I want to be able to see which users do certian functions on the website. However, I get this error message: Notice: Undefined index: I know what the error means but I don't know how to fix it, any help?
Use session_start() in every page where you want to work with sessions and as you are setting $_SESSION['username'] in loging.php page so you need to change
echo "Welcome" .$_SESSION[''];
with
echo "Welcome" .$_SESSION['username'];
In this way, you will be able to get the session of the username in index.php which you have set in loging.php page.
Can anyone from here please let me know how to do that?
Please start a new thread for your question instead of hijacking someone else's. Also, when doing so, please wrap your code blocks in this forum's [code]...[/code]
tags. (Unfortunately, the </>
button in the edit window is only suitable for in-line mono-spaced text, not for code blocks. )
I'll be locking this thread so that it doesn't get confused with responses to 2 different questions.