PHP5 mysql and linux help

windows

Guest
I have been looking and working on getting php5 mysql and apache2 working on Suse10 for a couple of weeks now. Here is the problem:

I finally get mysql set up so that I can access it through a terminal, but when I try to retrieve information from mysql with php, I get the header that I have put in HTML but nothing else??

here is the code that I wrote if it helps;

<HTML>
<HEAD>
<TITLE>
Displaying tables with MySQL
</TITLE>
</HEAD>

<BODY>
<CENTER>
<H1>Displaying tables with MySQL</H1>

<?php
$connection = mysql_connect("localhost","root","")
or die ("Couldn't connect to server");
$db = mysql_select_db("produce",$connection)
or die ("Couldn't select database");

$query = "SELECT * FROM fruit";
$result = mysql_query($query)
or die("Query failed: ".mysql_error());

echo "<TABLE BORDER='1'>";
echo "<TR>";
echo "<TH>Name</TH><TH>Number</TH>";
echo "</TR>";

while ($row = mysql_fetch_array($result))
{
echo "<TR>";
echo "<TD>", $row['name'], "</TD><TD>", $row['number'], "</TD>";
echo "</TR>";
}

echo "</TABLE>";

mysql_close($connection);

?>
</CENTER>
</BODY>
</HTML>

I get no error messages or anything, just the header and a blank page. I am pretty sure it has something to do with putting --with mysql or something of that nature into some file somewhere but I can't seem to find anyone who can tell me which file or how to set this up from the terminal.

ThanksCan you just tell me if you have php debug level set to error_reporting = E_ALL in your php.ini file? If not, try setting it to that for the moment and try running the script again. That should hopefully make it spit out an error. Php works by itself I take it?Error_reporting is set to E_ALL so that won't help us much. PHP does work by itself, I have been working with it for a couple of weeks without DB support.

I am also wondering if maybe something in my code is wrong or something because when I try to look at the code by selecting "View->Page Source" I get the HTML code but not the code for PHP?? I know that in the past when there is an error with my code that has happened to me, but for the life of me I can't find anything wrong.That is weird. I have tried running the code you loaded on my server and it runs fine (spits out an error about the login details as it should) so there is no syntax or running problems with the code. It's very strange that it spits out not errors or anything on your server. I will have a think about it.what is the setting of display_errors in your php.ini??

Does a die("foo") show a message in a script without DB interaction?I am also wondering if maybe something in my code is wrong or something because when I try to look at the code by selecting "View->Page Source" I get the HTML code but not the code for PHP??No, that is what is supposed to happen: the client isn't supposed to receive any PHP, only what is produced by running it.
 
Back
Top