-2

When I try to open the file register.php from the localhost(localhost/PrimaAppAndroid/register.php), the page remains white, and if I try to see the source file it is empty. If I leave the php part from register.php, it works fine even if I don't change the extension php in html.

I have seen a similar question and I added AddType application/x-httpd-php .php at the end of my apache2.conf file but nothing changed. How can fix this?

Here the sources: register.php

<?php 
/*
Our "config.inc.php" file connects to database every time we include or require
it within a php script.  Since we want this script to add a new user to our db,
we will be talking with our database, and therefore,
let's require the connection to happen:
*/
    require("config.inc.php");
?>

<h1>Register</h1> 
<form action="register.php" method="post"> 
    Username:<br /> 
    <input type="text" name="username" value="" /> 
    <br /><br /> 
    Password:<br /> 
    <input type="password" name="password" value="" /> 
    <br /><br /> 
    <input type="submit" value="Register New User" /> 
</form>

config.inc.php:

<?php 

    // These variables define the connection information for your MySQL database 
    $username = "root"
    $password = "root"
    $host = "localhost"
    $dbname = "cinemapreverificasql"

    // Tis is the way we saw in class
    $conn = mysql_connect($host, $username, $password) or die("Errore nella connessione MySQL");
    mysql_select_db($dbname, $conn) or ide("Database inesistente");
?>
Community
  • 1
  • 1
giacomotb
  • 607
  • 4
  • 10
  • 24
  • 2
    [**Please, don't use `mysql_*` functions in new code**](http://stackoverflow.com/q/12859942). They are no longer maintained [and are officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). See the [**red box**](http://uk.php.net/manual/en/function.mysql-connect.php)? Learn about [*prepared statements*](http://en.wikipedia.org/wiki/Prepared_statement) instead, and use [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) - [this article](http://php.net/manual/en/mysqlinfo.api.choosing.php) will help you decide which. – Francisco Presencia Dec 28 '13 at 14:52
  • Check your PHP error log. – Saturnix Dec 28 '13 at 14:53
  • 1
    Allowing your app to connect to your db as root is never a good idea. – vascowhite Dec 28 '13 at 14:56
  • Thank you for the suggestion, and I explain you here the motivation: in the school where I go in the test we have to use this method to connect, so I would like try it an see if it works, and I connect as a root because this is not the definitive application, I have just created the database and I just try to connect it – giacomotb Dec 28 '13 at 15:00
  • did you tried my suggestions? – Christian Giupponi Dec 28 '13 at 15:04
  • Yes, with yours it works, and are the most complete, thanks @ChristianGiupponi – giacomotb Dec 28 '13 at 15:10
  • why did you remove the accept mark? – Christian Giupponi Dec 28 '13 at 15:19

4 Answers4

2

No semi-colons in config.inc.php variables?

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
user1121487
  • 2,662
  • 8
  • 42
  • 63
2

another possible source of the error:

mysql_select_db($dbname, $conn) or ide("Database inesistente");

should probably be

mysql_select_db($dbname, $conn) or die("Database inesistente");
serakfalcon
  • 3,501
  • 1
  • 22
  • 33
2

Ciao Giacomotb, if you post your code correctly there is a typo in your config.inc.php file.

mysql_select_db($dbname, $conn) or ide("Database inesistente");

as you can see at the end you use the die function but you wrote ide, just fix it and it works

plus you forgot the semicolon at the end of your php variables.

$username = "root"
    $password = "root"
    $host = "localhost"
    $dbname = "cinemapreverificasql"

must be

$username = "root";
    $password = "root";
    $host = "localhost";
    $dbname = "cinemapreverificasql";
Christian Giupponi
  • 7,408
  • 11
  • 68
  • 113
1

i noticed you code having errors as (;) is missing in the end of varaiables you declare.

<?php 

    // These variables define the connection information for your MySQL database 
    $username = "root";
    $password = "root";
    $host = "localhost";
    $dbname = "cinemapreverificasql";

    // Tis is the way we saw in class
    $conn = mysql_connect($host, $username, $password) or die("Errore nella connessione MySQL");
    mysql_select_db($dbname, $conn) or ide("Database inesistente");
?>

and the other thing try by renaming your file which is config.inc.php and repalce name to config_inc.php

Engr Saddam Zardari
  • 1,057
  • 1
  • 14
  • 27