I want to run an hourly php script that updates my mysql server. I put the scripts into a folder /etc/cron.hourly. But I am getting an error.
#!/usr/bin/php
<?php
$connection=new pdo('mysql:host=HOST;dbname=DATABASE','ROOT','PASS');
$prepare=$connection->prepare('update TABLE set COLUMN=COLUMN+?');
$prepare->execute([1]);
?>
I keep getting this error.
How do I get the mysql part of the php to work as well? Is there a directory to connect mysql driver to the file as well?
You will need to check so that the driver is installed. This can be done by check the output of phpInfo() or using php cli:
phpInfo();
or:
php -m
If not installed then simply install it and restart apache:
sudo apt-get update
sudo apt-get install php5-mysql
sudo service apache2 restart
Related
I am a newbie to Linux. I was trying to install lamp stack in linux-mint. I used this command sudo apt-get install apache2, and looks like this is working. I enter the localhost in my browser and it shows the apache2 ubuntu default page. but the problem is when I create a info.php file in /var/www/html this directory with some basic PHP code <?php phpinfo(); ?>, instead of showing PHP details and versions, it is showing me the the raw PHP code in the browser <?php phpinfo(); ?>. I've tried some solution from StackOverflow
but nothing works. how can I fix this?
You did not have PHP installed or maybe your php is not enable.
you can do:
For install -> sudo apt-get install php php-mysql
For enable ->
sudo a2enmod php7
sudo service apache2 restart
this is important sudo service apache2 restart
Recently i installed LAMP on Linux Mint. I successfully installed it and now just run this commands on terminal for checking the version :
apache2 -v
php -v
mysql -v
This is the result :
I dont have any problem with localhost because now i'm running phpinfo() function correctly and localhost (apache and php) is ok. but for database is that :
in orther to instal phpmyadmin you need to install mysql before cotinunig
so it said that MySQL is needed. as you see i had installed mySQL before and now i have problem with checking the version.
im trying to config phpmyadmin but here is:
so i think this is the cause of mySQL.
what is the problem ?
As the mysql extension is not part of a default PHP7 installation anymore (http://php.net/manual/de/mysql.php), you need to install it with
sudo apt-get install php-mysql
This should install and activate the mysql drivers. You will have to restart apache afterwards by
sudo service apache2 restart
If you have already the mysql package installed, check the php.ini under /etc/php/7.1/apache2/php.ini for the line
extension=mysql.so
Maybe phpmyadmin works with mysqli (extension=mysqli.so) too.
To install php7 and php5 in parallel, check out this guide:
http://lornajane.net/posts/2016/php-7-0-and-5-6-on-ubuntu
I have already solved this problem by searching for a long time.
Everytime for the first time you use mysql after you turn on the computer,you should execute the following sentence:
net start mysql80
80 is mysql's version.
Remember:you should run the cmd with administrator privileges
Best wishes!
I'm following this link: click here!
I ran
sudo apt-get update && sudo apt-get install phpmyadmin
Then I restarted apache2 by using this command:
sudo service apache2 restart
Then I went to http://localhost/phpmyadmin in browser and I got this error:
Not Found
The requested URL /phpmyadmin was not found on this server.
Where did things go wrong?
P.S: This is the 3rd time that I'm trying to install phpmyadmin.
Look at this: http://tecadmin.net/install-phpmyadmin-in-ubuntu/
You have to edit your conf file
You must have a LAMP server in order to work with phpmyadmin.
In your case, I think you haven't installed MySQL.
You can install the entire LAMP by the following command.
sudo apt-get install lamp-server^
It’s important to remember the caret (^) at the end of the command.
During the installation, MySQL will ask you to set a root password.
Step by step installation of LAMP server is described in this link.
As you have already installed phpmyadmin, you now need to configure apache.
sudo nano /etc/apache2/apache2.conf
Add the following to the bottom of the file:
# phpMyAdmin Configuration
Include /etc/phpmyadmin/apache.conf
Restart apache with the following command.
sudo service apache2 restart
Now phpmysql will be working in http://localhost/phpmyadmin/.
Am running a project based on PHP for the first time in my machine, got error in php-sdk path saying Facebook needs the CURL PHP extension. What should be done to make it work ?.
Enable the curl php extension.
Follow this steps to enable
Install php curl
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl php5-mcrypt
Open php.ini file and add this line after finish installation
extension=curl.so
Restart the apache server
/etc/init.d/apache2 restart
Then in a new php page type:
<?php
phpinfo();
?>
You will find curl is included in php info page.
I am trying to install phpmyadmin on a VPS LEMP-stack.
I created an info.php, which is perfectly reachable when I call my server's IP in my browser, revealing all relevant php-info, i.e. nginx is running.
However, after installing phpmyadmin, which I try to access via http://192.xxx.xxx.x/phpmyadmin/, I get the following error message:
The mysqli extension is missing. Please check your PHP configuration.
I already installed php5-mysql via sudo apt-get install php5-mysql, restarted nginx and cleared my browser-cache, but the situation remains.
Could you please advice me what goes wrong?
mysql and mysqli are two different things.
You have to install the mysqli library:
sudo apt-get install php5-mysqli
Don't forget to also restart the php fpm workers, because that's where the mods get loaded, not in nginx.
/etc/init.d/php5-fpm restart
Update:
I was wrong, the php5-mysql package contains the mysql AND the mysqli library.
It must be enough for you to restart the php workers :-)