Jump to content

Blank screen


boen_robot

Recommended Posts

I recently had to reinstall the server of my friend and install everything all over again.I installed Apache, added a few settings to the configuration file to run PHP and copyed the php5ts.dll to it's proper destination. Apache and PHP work like a charm. So far so good. I now wanted to add MySQL and XSLT support. Until few minutes I was getting errors with every PHP that was using extensions, until I added the PHPiniDir directive. Now, with phpinfo() I can see the extensions are avaiable and installed properly. I even tryed enabling additional one, and saw it right after the change. Everything seems perfect, except... Now that I run a file that uses extension, I get a blank screen instead of an error message or the proper result. The source code of the output I get is this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><META http-equiv=Content-Type content="text/html; charset=windows-1251"></HEAD><BODY></BODY></HTML>

And what I have added in Apache's configuration to enable PHP is this:

ScriptAlias /php/ "d:/php/"AddType application/x-httpd-php .phpAction application/x-httpd-php "/php/php-cgi.exe"LoadModule php5_module "d:/php/php5apache2_2.dll"SetEnv PHPRC "d:/php"PHPiniDir "D:/php"

The extension_dir directive in php.ini is set properly like this:

extension_dir = "D:\PHP\ext"

And phpinfo() does detect enabling and disabling changes, that is, it shows which extensions are suppose to be avaiable, so what could be the problem?Oh and, the source of the XSLT extension test:

<?php$xml = new DomDocument;$xml->load('test.xml');$xsl = new DomDocument;$xsl->load('test.xsl');$xslt = new Xsltprocessor;$xslt->importStylesheet($xsl);$transformation = $xslt->transformToXml($xml);echo $transformation;?>

Where of course, test.xml and test.xsl exist in the same folder and are well formed XML documents that should output proper stuff.I would have guessed it's some sort of misconfiguration if there were error messages (as before I added the PHPiniDir) but blank screen :) ?I can't stop asking myself how did I enabled XSLT support the first time. If that works, MySQL should too.P.S. I'm using Windows XP SP2, Apache 2.2.2, PHP 5.2.0 and MySQL 5.0.1. I had to reinstall Windows, because the HDD was placed on another PC, resulting in a... how you say... driver incompatability I think. We had to place that HDD elswhere. On that other mainboard it made the server crash whenever someone requests a file larger then 200KBs. If any additional info is requred, please do tell. Infact, here's a shot of the phpinfo().

Edited by boen_robot
Link to comment
Share on other sites

I fixed the XSLT issue. The problem was that I accidently renamed the XML file to text.xml instead of the correct test.xml.Now to double check the MySQL spelling. That might be the problem there too.[edit] It doesn't work. I didn't noticed any errors. Here's the source of the MySQL test I use:

<?php$mysqli = new mysqli('localhost','root','admin');$mysqli->select_db('demo');$result = $mysqli->query("SELECT * FROM members");while($row = $result->fetch_assoc()) {	print $row['firstName'] . ' ' . $row['lastName'] . '<br/>';	}$result->close();?>

Where the database "demo" and the table "members" with all of it's stuff was previously created in MySQL's command line interface. Here's a shot of the CMD:mysqlcmd8fi.pngP.S. I'm not afraid to reveal my password scince it's not the one I intend to use permanently and you won't be able to access the DB anyway. I've disabled remote access.

Edited by boen_robot
Link to comment
Share on other sites

[edit] It doesn't work. I didn't noticed any errors. Here's the source of the MySQL test I use:
Try this Boen, it will display errors with the connection using mysql_error() function. I think it is good practise to use this within die() to report any errors, saved me lots of time.
<?php ini_set ('display_errors', 1);error_reporting (E_ALL & ~E_NOTICE);// Connect and select.if ($dbc = @mysql_connect ('localhost', 'root', 'admin')){if (!@mysql_select_db ('demo')){die ('<p>Could select the database because: <b>' . mysql_error() . '</b></p>');}} else {die ('<p>Could not connect to MySQL because: <b>' . mysql_error() . '</b></p>');}// Define the query.$query = 'SELECT * FROM members';if ($r = mysql_query ($query)) { // Run the query.// Retrieve and print every record.print '<table border="1"><tr><td>First Name</td><td>Surname</td></tr>';while ($row = mysql_fetch_array ($r)) {print " <tr>  <td>{$row['firstName']}</td>  <td>{$row['lastName']}</td>  </tr>";}print '</table>';} else { // Query didn't run.die ('<p>Could create the table because: <b>' . mysql_error() . "</b>. The query was $query.</p>");} // End of query IF.mysql_close(); // Close the database connection.?>

Link to comment
Share on other sites

After you are done testing though you may want ot remove the mysql_error because it gives away info about your database. I have dicovered this will practicing my SQL injection on random community sites (local sites I knew where built poorly) and when my injection attempts caused an error it showed the mysql_error info that told me what constraints, etc I was violating and actually helped me know the fields they keep their usernames and passwords in, which lead to me hacking in.ASP.Net has 3 types of error messages (defined in config file) 1 - "off" shows full compiler error messages2 - "on" shows no message3 - RemoteOnly shows user friendly messages with no technicall info.

Link to comment
Share on other sites

Theese are only tests here though, but I'll keep that in mind.@scott100 your code works, but what it uses is MySQL. What about MySQLi? That is what I initially wanted :) . Oh well, MySQL would do the job too in the meantime.

Link to comment
Share on other sites

Read the FAQ at the download page of the PHP connector. According to it:

What is the difference between the mysql and mysqli extensions for PHP? The mysql extension does not support the full functionality of MySQL versions greater than 4.1.0, such as Stored Procedures, Triggers, Views, Precision Math and much more. In order to use all functions of the latest MySQL Server Releases you have to use the mysqli extension that is available as of PHP 5.0.The main features of the mysqli extension are:
  • access to all MySQL 4.1/5.0 features
  • a procedural interface that is similar to the mysql extensions
  • an object-oriented interface that is easier to extend than the procedural interface

See also MySQL 5.0 Reference Manual :: MySQL PHP API

Link to comment
Share on other sites

  • 1 month later...

I couldn't get mysqli to work either until adding this line 'extension=php_mysqli.dll' below the 'extension=php_mysql.dll' line in the Dynamic Extensions section of the php.ini file, also making sure the semicolon was removed from the beginning.

Link to comment
Share on other sites

I was actually able to at one point by the way. At home to be exact. I used Apache 2.2.2 and PHP 5.2.0-dev (the latest stable version at that time) and I just added the extension=php_mysqli.dll thing. The fine line is that I used the SQLi connector that was bundled with PHP, not the one offered at MySQL's site and also that the extension dir was explicitly set to the exact path where the extensions were ("D:\PHP\ext" in my case).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...