Hi,
I am trying to learn mysql and php. I am using the book 'MySQL/PHP Database Applications' by Greenspan-Bulger and there it is a learning application that does not work! I've tried everything! I am suppose to be able to type my own select commands to learn and see what happen with the outprint but it just does not happen! Here is the code, I bet it is just a small simple problem that you gurus can see in just a flash! Please help me..
Thanking you...
Greetings from Martin
<?php
if(!isset($query) || empty($query))
{$query = "select * from users";}
$query=stripslashes($query);
mysql_connect("localhost", "user", "password")
or die("Could not connect to database.");
mysql_select_db("users") or
die("Cannot select database");
$result = mysql_query($query) or die( mysql_error() );
$number_cols = mysql_num_fields($result);
echo "<b>query: $query</b>";
echo "<table border = 1>\n";
echo "<tr align=center>\n";
for ($i=0; $i<$number_cols; $i++)
{
echo "<th>" . mysql_field_name($result, $i). "</th>\n";
}
echo "</tr>\n";//end table header
//layout table body
while ($row = mysql_fetch_row($result))
{
echo "<tr align=left>\n";
for ($i=0; $i<$number_cols; $i++)
{
echo "<td>";
if (!isset($row[$i])) //test for null value
{echo "NULL";}
else
{echo $row[$i];}
echo "</td>\n";
}
echo "</tr>\n";
}
echo "</table>";
?>
<form action="<?php echo $PHP_SELF;?>" method="get">
<input type="text" name"query" size="50"><br>
<input type="submit">
</form>