Page 1 of 1

Getting blank pages with new install

Posted: Sat Mar 10, 2007 3:45 am
by majyk
I installed PHP 5 on Windows Vista. PHP seems to work fine. I then wanted to use mysql. 5 So I downloaded the extensions. The mysql instructions mentioned I need to change some settings in php.ini. PHP never would recognize the mysql connect() function. I then viewed phpinfo() and it said the configuration file was in c:\Windows. That's incorrect because such a file doesn't exist there. I then added php.ini to the Windows folder. Now I get only blank pages when accessing php files. phpinfo() doesn't even print anymore.

Any suggestions on what is wrong?

Thanks.

Posted: Sat Mar 10, 2007 4:00 am
by volka
copy php.ini-recommended to c:\windows\php.ini and restart the webserver (software)

Posted: Sat Mar 10, 2007 10:45 am
by majyk
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Thanks.  It seems to render fine after do what you said.  I had already done that a number of times and it never worked.

I'm running this code and getting a blank white page:

Code: Select all

<html>
    <head>
        <title>Example</title>
    </head>
    <body>

        <?php 
        phpinfo();
        echo "Hi, I'm a PHP script!"; 
        
        $db = mysql_connect('dev', 'myuser', 'mypass') or die
        ('Error connecting...');
        if(!(mysql_select_db('mydb', $db))
        {
        die("Can't connect.");
        }
        mysql_close($conn);
        ?>

    </body>
</html>
If I take out all of the database code, phpinfo displays. How can I tell if this is connecting or not? Thanks.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sat Mar 10, 2007 11:51 am
by feyd
Run the following in a new file and tell us the results please.

Code: Select all

<?php

$neg = array('off', 0, false, '', null);
$flags = array(
	'Register Globals' => 'register_globals',
	'Short Tags' => 'short_open_tag',
	'Display Errors' => 'display_errors',
	'Magic Quotes GPC' => 'magic_quotes_gpc',
	'Magic Quotes Runtime' => 'magic_quotes_runtime',
	'Magic Quotes Sybase' => 'magic_quotes_sybase',
);
$ve = phpversion();
$os = PHP_OS;
$er = intval(error_reporting());
foreach ($flags as $n => $v)
{
	$flags[$n] = (in_array(strtolower(ini_get($v)), $neg) ? 'Off' : 'On');
}
$flags['Config file'] = get_cfg_var('cfg_file_path');
if (empty($flags['Config file']))
{
	$flags['Config file'] = '-';
}
$cli = (php_sapi_name() == 'cli');
$eol = "\n";

$gle = get_loaded_extensions();
$rows = array();
$le = '';
$wide = 4;
$j = count($gle);
$pad = $wide - $j % $wide;
$len = max(array_map('strlen', $gle));
$func = create_function('$a', 'return str_pad($a, ' . intval($len) . ');');
$gle = array_map($func, $gle);
for($i = 0; $i < $j; $i += $wide)
{
	$le .= '   ' . implode('   ', array_slice($gle, $i, $wide)) . $eol;
}

$ec = array(
	'E_STRICT' => 2048, 'E_ALL' => 2047, 'E_USER_NOTICE' => 1024,
	'E_USER_WARNING' => 512, 'E_USER_ERROR' => 256, 'E_COMPILE_WARNING' => 128,
	'E_COMPILE_ERROR' => 64, 'E_CORE_WARNING' => 32, 'E_CORE_ERROR' => 16,
	'E_NOTICE' => 8, 'E_PARSE' => 4, 'E_WARNING' => 2, 'E_ERROR' => 1,
);

$e = array();
$t = $er;
foreach ($ec as $n => $v)
{
	if (($t & $v) == $v)
	{
		$e[] = $n;
		$t ^= $v;
	}
}
if (ceil(count($ec) / 2) + 1 < count($e))
{
	$e2 = array();
	foreach ($ec as $n => $v)
	{
		if (!in_array($n, $e) and $n != 'E_ALL')
		{
			$e2[] = $n;
		}
	}
	$er = $er . ' ((E_ALL | E_STRICT) ^ ' . implode(' ^ ', $e2) . '))';
}
else
{
	$er = $er . ' (' . implode(' | ', $e) . ')';
}

if (!$cli)
{
	echo '<html><head><title>quick info</title></head><body><pre>', $eol;
}

echo 'PHP Version: ', $ve, $eol;
echo 'PHP OS: ', $os, $eol;
echo 'Error Reporting: ', $er, $eol;
foreach ($flags as $n => $v)
{
	echo $n, ': ', $v, $eol;
}
echo 'Loaded Extensions:', $eol, $le, $eol;

if (!$cli)
{
	echo '</pre></body></html>', $eol;
}

?>

Posted: Sat Mar 10, 2007 12:06 pm
by majyk
Here are the results:

PHP Version: 5.2.0
PHP OS: WINNT
Error Reporting: 6143 (E_ALL)
Register Globals: Off
Short Tags: Off
Display Errors: Off
Magic Quotes GPC: Off
Magic Quotes Runtime: Off
Magic Quotes Sybase: Off
Config file: C:\Windows\php.ini
Loaded Extensions:
bcmath calendar com_dotnet ctype
session filter ftp hash
iconv json odbc pcre
Reflection date libxml standard
tokenizer zlib SimpleXML dom
SPL wddx xml xmlreader
xmlwriter ISAPI

I then turned on Display Errors. I get this now:

Warning: mysql_connect() [function.mysql-connect]: Host 'VistaDev.gateway.2wire.net' is not allowed to connect to this MySQL server in E:\Dev\www\temp\phptest.php on line 10
Could not connect: Host 'VistaDev.gateway.2wire.net' is not allowed to connect to this MySQL server

VistaDev is the name of the box with mssql server on it. 2wire is the dsl modem/router I'm using. I have an ethernet cable running between two PCs. I'm on an XP machine and connecting to a Vista machine, where the mssql server is. It shouldn't involve the router. When I have anything going between the two PCs, it always goes across the wire. I get the same error even if I'm on the Vista box. Do you know why it is doing this?

Thanks.

Posted: Sat Mar 10, 2007 12:31 pm
by feyd
The installation of MySQL on the hosting server must allow remote connections from the server performing the request. Normally these are disabled as it can lead to a security hole if not properly set up.

Posted: Sat Mar 10, 2007 1:00 pm
by majyk
Thanks. I'm not sure why it refuses. In my.ini under [mysqld], I don't have any binding entries. Shouldn't it then allow all connections?

Posted: Sat Mar 10, 2007 1:02 pm
by feyd
The connection refusal is up to the user privileges granted.

Posted: Sun Mar 11, 2007 1:04 am
by majyk
After using 127.0.0.1, it works fine. Thanks.