[OCLUG-devel] PHP/MySQL

Doug Jolley ddjolley at gmail.com
Mon Jan 15 12:00:43 PST 2007


Hi --

I'm appending a short PHP program that I have written.  It is intended to
establish and test an interface to a MySQL database.  The program
happens to be named test1.php.  When I run the program manually
by entering 'php test1.php' at a shell prompt it works perfectly and I
see an output line that says, '<p>Row count: 6</p>'.  That is just
what I would expect.  However, when I use a browser to display
test1.php, I only see the 2 header lines.  An examination of the source
(i.e., view source) reveals that the thing stalls out and has no output
after the 2nd header line.  My only guess would be that I have some
sort of mis-configuration of PHP but I have no idea what it would be.
If anyone has any thoughts, I'd love to hear them.  Thanks for any
input.

      ... doug

<html>
 <head>
  <title>Test 1</title>
 </head>
 <body>
  <h2 style="text-align: center">
Test 1
  </h2>
  <h2 style="text-align: center">
PHP To MySQL Connection Test
  </h2>
<?php
$link=mysql_connect("localhost","root","mypassword");
if (!$link) {
  die("Couldn't connect to the database.\n");
 }
mysql_select_db("penumbra")
 or die("Couldn't open the database.  Error: ".mysql_error());
$result=mysql_query("SELECT * FROM roll_a_dex",$link);
if (!$result)
  die("Failed to receive a result from the database.\n");
$row_count=mysql_num_rows($result);
print "<p>Row count: $row_count</p>\n";
mysql_close($link);
?>
 </body>
</html>
~
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://localhost.localdomain/pipermail/oclug-devel/attachments/20070115/c70c5131/attachment.html 


More information about the OCLUG-devel mailing list