Ubuntu: Can't run PHP script accessing my Mysql databse


I've created LAMP server in my ubuntu desktop. I've also made a sample database in Mysql having 6 columns. I can access it through the terminal. I've also created a php script for accessing the same. But when I'm not able to run it in the web browser....

It just shows me a blank page....and nothing else !!!!

Below is my code:

// I'd typed http://_MY_IP_ADDRESS_/_FILE_NAME_.php in the browser to run this file    <?php    include('db_login.php');            // include the login info of the user  $connection = mysql_connect($db_host, $db_username, $db_password); // make the connection    if( !$connection )  {      die("Couldn't connect to the database: <br />", mysql_error());  }        $db_select = mysql_select_db($db_database);// select the database    if( !$db_select )  {      die("Couldn't select the database: <br />", mysql_error());  }    // developing the query    $select = 'select';  $coloumn = ' * ';  $from = 'from';  $table = 'table';    $query = $select.$coloumn.$from.$table;                       $result = mysql_query($query);                              if( !$query )  {      die("Couldn't query the database: <br />", mysql_error());  }     // fetching and displaying the result    while($result_row = mysql_fetch_row($result))  {      echo "A".$result_row[1]."<br />";  echo "B".$result_row[2]."<br />";  echo "C".$result_row[3]."<br />";  echo "D".$result_row[4]."<br />";  echo "E".$result_row[5]."<br />";  echo "F".$result_row[6]. "<br /><br />";  }    mysql_close($connection);     // closing the connection    ?>  


Syntax problems on line 8:

die("Couldn't connect to the database: <br />", mysql_error());  

. is used as concatenation, not ,

Same problem on line 15 and 30.

Also, turn on error reporting. To do so:

ini_set('display_errors',1);  ini_set('display_startup_errors',1);  error_reporting(-1);  

This will turn on all errors.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »