Artisan command says : Dotenv values containing spaces must be surrounded by quotes - php

I'm trying to know the list of artisan command by using php artisan list . and the command return me the following error
[Dotenv\Exception\InvalidFileException]
Dotenv values containing spaces must be surrounded by quotes.
What is wrong?
Thanks in advance.

You should remove all spaces from .env file to make an app work again.
If you have to use spaces, instead of this:
VAR=some data
Use quotes:
VAR="some data"

Verify your .env file. You need to check for the following:
Any extra or non-needed spaces
If you have any strings with spaces, make sure to surround them in quotes
Example:
varaible=123 Test
Needs to be
varaible="123 Test"

Make sure that:
all variables with spaces are surrounded by quotes
there are no semi-colons

if you use two word for username or database name in .env,put it inside a double quotation.

First check env.
If your var value with space so check value in double quotes. like,
MAIL_FROM_NAME="Sarvajanik School"
If you use single quotes then the possible to got this error containing spaces must be surrounded by quotes

Related

PHP CLI get *raw* commandline

Is it possible to get the exact raw command line in PHP as typed in?
$ ./example.php --key1="value" --key2='value' --key3= value-with-leading-double-blank
I'd like to now if value was enclosed in single or double quotes and if any blanks were typed. Obviously implode(' ', $argv[]) does not work as surrounding quotes and blanks have been stripped already.
Any hints?

when phinx migrate, string in double quotes("") is not recognized correctly

I have migration using phinx, above picture is the data seed.
(I just boxed out some sections, sorry for it)
As you can see, there are blue color characters which are
not recognized and I don't know why...
They are within double quotes " " and I think all kind of quotes (", ', `) match correctly
but when I do
$ php phinx migrate
the result turns to be like this:
Somehow those blue characters are recognized as variables instead of strings? Any guess for the possibilities will be appreciated. I'm using VSCode(don't think I have to say this but... yes)
When inside double quotes, PHP interprets $something as a variable, so in your migration code PHP tries to get the value for all those blue values in the picture.
In order to get it to work, you need to either use single quotes and escape every single single quote inside the queries, or keep your double quotes and escape only the dollar signs (when applicable).
<?php
$a = "test";
echo "this is a $a"; // this is a test <-- this is what's happening to you
echo 'this is a \'$a\''; // this is a '$a' <-- one option
echo "this is a \$a"; // this is a $a <-- another opcion
So it would look something like this:
$this->execute("INSERT INTO table (email, password) VALUES ('email#test.com', '\$2y\$10\$aerjgap2341234ommubi1234123');

how to not parse double quotes within double quotes

Hello there :) I have a script in PHP that creates a file (with the function "file_put_contents()") , and it will put the contents of a PHP file within the file it just created. Within the PHP file, there are double quotations, so as i try to implement the code that i want to put into this newly made PHP file, it has double quotations, and the way how file_put_contents works is the second part of it uses double quotations as well.
To put it into perspective, this is how it goes: file_put_contents('file.php',"code with "" in it")
so as you can see, the double quotations get in the way of the PHP files double quotes.
My question is, how do i get the text within the quotes to not parse?
Thanks
use \ more info
file_put_contents('file.php',"code with \"\" in it")
or use ' to quote second param
file_put_contents('file.php','code with "" in it')
Wrap the string which contains double quotes in a string literal defined using single quotes.
file_put_contents('file.php','code with "" in it');
"Escaping" is what you're looking for. As always, the manual holds all your answers:
https://secure.php.net/manual/en/language.types.string.php
You just need to escape the double quotes like this : file_put_contents('file.php',"code with \"\" in it")
For more information : http://php.net/manual/en/language.types.string.php
Try using addslashes("codewith dowble quotes") to over come this issue

PhP TextArea each line with explode and foreach postgresql

It's a very simple question. I have a textarea. In this textarea are names. Every name in a new row.
Brad Pitt
LMFAO
Green Day
and so on...
I would like to put this names in a database. I tried it with explode() and foreach, but it didn't work. :/
Here is the code:
$kilencedik=array();
$kilencedik=explode('\n',$_POST['9']);
foreach($kilencedik as $nev9) {
$adat9 = pg_escape_string($nev9);
pg_query($kapcsolodas, "INSERT INTO diakok (nev, ev) values ('$adat9', '9')");
}
I'm using postgreSQL with PHP.
It's a ' problem change '\n' to "\n".
Try using explode(PHP_EOL, $_POST['9']);
Using PHP_EOL is more compatilbe across platforms.
If you don;t want to use that you need to at least use double quotes around the \n instead of single quotes. Using double quotes, PHP will interpret that as the newline character whereas using single quote will look for literal \n as string segment to explode on.

PHP can't read filename which has special character !

i have problem with file() in php. The function can't read a file start with ! or $ like !textfile.txt or $textfile.txt, i try with fopen() and it happen as a same way. I have no idea how to solve this. I hope someone can help
Appreciate any help.
The filename "$textfile.txt" will not work as expected because variable interpolation happens in double quotes as a result value of variable $textfile will be appended with .txt and the result will be used as filename. If $textfile is undefined (which mostly is the case), .txt will be used as the filename.
To fix this use single quotes around the filename as '$textfile.txt' or if you have to use double quotes, escape the $ as: "\$textfile.txt"
But I see no problem with "!textfile.txt"
echo file_get_contents("\$test.txt");
Works.
You need to escape special characters or use single quotes.

Categories