It’s very easy like this :
$var = 'Hello my name is Alex?';
if (strpos($var, 'name') !== false) {
echo 'true';
}
It’s very easy like this :
$var = 'Hello my name is Alex?';
if (strpos($var, 'name') !== false) {
echo 'true';
}
Using PDO (for any supported database driver):
$stmt = $pdo->prepare('SELECT * FROM users WHERE name = :name');
$stmt->execute(array('name' => $name));
foreach ($stmt as $row) {
// Do something with $row
}
2. Using MySQLi (for MySQL):
$stmt = $dbConnection->prepare('SELECT * FROM employees WHERE name = ?');
$stmt->bind_param('s', $name); // 's' specifies the variable type => 'string'
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
// Do something with $row
}
Q1: this notice means $varname is not defined at current scope of the script.
Q2: Use of isset(), empty() conditions before using any suspicious variable works well.
Solution
// recommended solution for recent PHP versions
$user_name = $_SESSION['user_name'] ?? '';
// pre-7 PHP versions
$user_name = '';
if (!empty($_SESSION['user_name'])) {
$user_name = $_SESSION['user_name'];
}
Anoter solution :
// not the best solution, but works
// in your php setting use, it helps hiding site wide notices
error_reporting(E_ALL ^ E_NOTICE);
mkdir -p /var/run/mysqld
chown mysql:mysql /var/run/mysqld
sudo /etc/init.d/mysql stop
sudo mysqld_safe –skip-grant-tables &
mysql -uroot
use mysql;
update user set authentication_string=PASSWORD("newpassword") where User='root';
flush privileges;
quit
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
mysql -u root -p
mysqld_safe Directory ‘/var/run/mysqld’ for UNIX socket file don’t exists
mkdir -p /var/run/mysqld
chown mysql:mysql /var/run/mysqld
sudo service mysql start
cd /var/run
sudo cp -rp ./mysqld ./mysqld.bak
sudo service mysql stop
sudo mv ./mysqld.bak ./mysqld
sudo mysqld_safe --skip-grant-tables --skip-networking &
mysql -u root
FLUSH PRIVILEGES;
SET PASSWORD FOR root@'localhost' = PASSWORD('my_new_password');
Edit this file
/opt/bitnami/apps/wordpress/conf/httpd-vhosts.conf
Change ServerName and ServerAlias to your domain,
then Add these lines
RewriteCond %{HTTP_HOST} ^yourwebsite.com
RewriteRule (.*) https://www.yourwebsite.com/$1 [R=301,L]
Then restart apache
sudo /opt/bitnami/ctlscript.sh restart apache
Permission issues with WordPress
sudo chown -R bitnami:daemon /opt/bitnami/apps/wordpress/htdocs/wp-content/cache
sudo find /opt/bitnami/apps/wordpress/htdocs/wp-content/cache -type f -exec chmod 664 {} \;
sudo find /opt/bitnami/apps/wordpress/htdocs/wp-content/cache -type d -exec chmod 775 {} \;
sudo chown bitnami:daemon /opt/bitnami/apps/wordpress/htdocs/wp-config.php
sudo chmod g+w /opt/bitnami/apps/wordpress/htdocs/wp-config.php
sudo chown bitnami:daemon /opt/bitnami/apps/wordpress/htdocs/.htaccess
sudo chmod g+w /opt/bitnami/apps/wordpress/htdocs/.htaccess
Sometimes you need to get your virtual host file, you can get them by :
a2query -s
or
apachectl -S
As you may have noticed, you have a block called Sidebar, to modify this SideBar, you just have to modify your theme.
My theme was done with Boostrap which implements the task,
Go in Appearance> Editor> Edit single.php
Before:
<section id="section-block" class="site-content">
<div class="container">
<div class="row">
<!--Blog Posts-->
<?php
echo '<div class="col-md-'.( !is_active_sidebar( "sidebar-primary" ) ?"12" :"8" ).' col-xs-12">';
?>
After :
<section id="section-block" class="site-content">
<div class="container">
<div class="row">
<!--Blog Posts-->
<?php // echo '<div class="col-md-'.( !is_active_sidebar( "sidebar-primary" ) ?"12" :"8" ).' col-xs-12">'; ?>
<?php echo '<div class="col-md-12 col-xs-12">'; ?>
<?php
/*
* if ( is_active_sidebar( 'sidebar-primary' ) ): ?>
<div class="col-md-4 col-sm-4 col-xs-12">
<div class="sidebar" >
<?php dynamic_sidebar( 'sidebar-primary' ); ?>
</div>
</div>
<?php endif;
*/
?>
I put everything in the comment, so that the side is not displayed!
Log in as root and place yourself at the root of your site directory
# Add group www-data
chown www-data:www-data -R wp-content/uploads/
# set permission 755
find . -type d -exec chmod 755 {} \;
# set permission 644
find . -type f -exec chmod 644 {} \;