PHP CORE LAB
580 FOLLOWERS
Quick reference for PHP best practices, PHP tutorials around the Web, PHP programming, PHP and MySQL.
How to resolve this issue “SELECT list is not in GROUP BY clause and contains nonaggregated column “
PHP CORE LAB
4y ago
We can resolve this issue by changing the sql mode in MySQL by this command
SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,’ONLY_FULL_GROUP_BY’,”));
After run this query you may need to RESTART MYSQL SERVICE.
If you are using PHPMYADMIN you can directly edit from PHPMYADMIN –
change the “sql_mode” setting as mentioned the in below screenshot.
Edit “sql_mode” variable and remove the “ONLY_FULL_GROUP_BY” text from the value
The post How to resolve this issue “SELECT list is not in GROUP BY clause and contains nonaggregated column “ appeared first on PHPCORELAB ..read more
PHP CORE LAB
4y ago
To enbale .htaccess go to /etc/apache2/ and open apache2.conf
to edit that file you need root permission.
to open this file in terminnal use below command
sudo nano /etc/apache2/apache2.conf
Change directory (<Directory) text as per below;
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
after doing this change restart apache server using
service apache2 restart
The post Enabling .htaccess file in Ubuntu appeared first on PHPCORELAB ..read more
PHP CORE LAB
4y ago
To check cURL we need to check PHP extension –
function _is_curl_installed() {
if (in_array (‘curl’, get_loaded_extensions())) {
return true;
}
else {
return false;
}
}
// Output text to user based on test
if (_is_curl_installed()) {
echo “cURL is <span style=\”color:blue\”>installed</span> on this server”;
} else {
echo “cURL is NOT <span style=\”color:red\”>installed</span> on this server”;
}
The post How to check cURL is install or not on server in PHP appeared first on PHPCORELAB ..read more
PHP CORE LAB
5y ago
What is Palindrome?
Palindrome is a word, phrase, sentence, or number that reads the same from both backward or forward. If you reverse the string it is same as original string.
$myValue = 121; // Define string madam,nitin ,1881,2002
$myArray = array(); // define php array
$myArray = str_split($myValue); //split the array
$len = sizeof($myArray); // use php function to get size of array
$newString = "";
//reverse the value
for ($i = $len; $i >= 0; $i--)
{
$newString.=$myArray[$i ..read more
PHP CORE LAB
5y ago
$num= 20; // It print all prime number till 20
for($j=2;$j<=$num;$j++ )
{
for($k=2;$k<$j;$k++ )
{
if($j%$k==0)
{
break;
}
}
if( $k == $j )
echo "Prime Number : $j <br />";
}
The post Write a program to print Prime number appeared first on PHPCORELAB ..read more
PHP CORE LAB
5y ago
$num = 6; // Change to any number
for($i=1 ; $i<=10 ; $i++)
{
echo $i*$num; // Multiply index to number
echo '<br>'; // For new line
}
The post Write a program to print table of any number appeared first on PHPCORELAB ..read more
PHP CORE LAB
5y ago
To get hostname we use PHP inbuilt function parse_url.
$url = 'http://google.com/dhasjkdas/sadsdds/sdda/sdads.html';
$parse = parse_url($url);
print $parse['host']; // prints 'google.comParsing Domain From URL In PHP
This function is not used for validate the given URL, it only breaks it up into the above parts.
The post How to get hostname from any url appeared first on PHPCORELAB ..read more
PHP CORE LAB
5y ago
In windows system you can not create a file without name it not allow you to create a .env file directly from the windows explorer. However, we can create .env file from command line of PHP console using following –
Stpes to create .env file
Step 1:
Create anything.txt file in same folder Step 2:
Choose any method Method 1 – If you have installed php then run this command in console php -r “copy(‘anything.txt’, ‘.env’);” Method 2 – Create a txt file called anything.txt open CMD and find its dir then run ” ren anything.txt .env ”
You can create .htaccess file using same method.
The post ..read more