问题
I bought hosting service tomorrow and from yesterday I am trying to solve problems. Problem is that PHP is not working on this server I don't know what is wrong first I used this code to connect to database
<?php
Create connection
$con=mysqli_connect("localhost","user","pass","database");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
else {
echo "Connected";
}
?>
It show me blank page when I upload it to server using ftp if I check source code it's also blank So I added this to check the error
ini_set('display_errors',1);
error_reporting(E_ALL);
then I got this error
Fatal error: Call to undefined function mysqli_connect() in /home/vidupda1/public_html/cont.php on line 6
After searching it was come to the point that mysql and mysqli extensions are not enabled in PHP.ini so I requested my hosting service provider to enable it (not replied yet)
After that I used this simple code to check if PHP is enabled or not
<html>
<title>Test</title>
<body>
<?php
echo "Hello World";
phpinfo();
?>
</body>
</html>
but It shows just Hello Word but not the phpinfo
So Tell me what is the acutal problem and would my problem solved after they enable these extensions ?
;extension=php_mysql.so
;extension=php_mysqli.so
;extension=php_pdo_mysql.so
回答1:
You need to enable mysqli
extension by removing the ;
extension=php_mysqli.so
回答2:
I am not sure, but I believe you cannot run phpinfo() on commercial websites due to security settings. The fact that you can echo out 'Hello World' means that PHP is working. Then I believe you should wait for your host reply.
Best regards Shahram
回答3:
just remove the ";" and restart the apache service
回答4:
If they disabled the mysql functions, it's also possible and likely they disabled phpInfo() as well. If you succeed in getting those changes, then your code should work fine.
来源:https://stackoverflow.com/questions/22651936/php-is-not-working-on-server