You are not logged in.

#1 2014-06-18 09:24:23

gvenkat1994
Member
Registered: 2014-04-13
Posts: 34

PHP script not running in browser

I'm a newbie at this, so please bear with me. I'm trying to learn PHP-MySQL. I have this script that I'm trying to run :

<?php
echo "Hell1o";
$host = "localhost"; 
$user = "root"; 
$pass = "a"; 

$r = mysql_connect($host, $user, $pass);

if (!$r) {
    echo "Could not connect to server\n";
    trigger_error(mysql_error(), E_USER_ERROR);
} else {
    echo "Connection established\n"; 
}

echo mysql_get_server_info() . "\n"; 

mysql_close();

?>

When I go to localhost/~home and click on the .php file that contains this script, nothing other than "Hello" is printed on browser screen. I have setup php and mysql to work. I have setup phpmyadmin and even it seems to work fine. Why aren't the other echo statements working?

Offline

#2 2014-06-18 09:33:20

gvenkat1994
Member
Registered: 2014-04-13
Posts: 34

Re: PHP script not running in browser

I'm sorry I just found out my error. Apparently mysql_connect is deprecated as of new versions of php. The correct syntax is mysqli_connect. The same goes for all other mysql commands.

Offline

Board footer

Powered by FluxBB