[KLUG Members] (Linux/Mac)AMP Question

Jon members@kalamazoolinux.org
Mon, 24 May 2004 14:53:31 -0400


Here's the problem - I have a dvd database in MySQL that I want to make 
searchable.  I have accomplished this with AMP on my Mac, but the search 
results when using AMP on my linux box are incorrect.  The coding is as 
follows -

1.Search Page
<html>

        <head>
                <title>Search The DVD Database</title>
        </head>
        <body>

     <tr>
     <td colspan="2" align="left">
     <table align="center" cellspacing="2" cellpadding="2" border="0" bgcol
234765">
     <tbody><tr><td bgcolor="#9a9aaa" align="center"><b>Search The DVD Data
/b></td></tr>
            <tr>
      <td valign="top">
      <table width="100%" border="0" bgcolor="#ffffff">
      <tbody><tr><td nowrap="nowrap" valign="top" bgcolor="#ffffff" align="
>

<br>
<form action=titlereturn.php method=GET>
Title Word Search: <input type="text" name="search">
<input type="submit" name="titlereturn" value="Search Titles">
</form>
<center> or
<br></br>
</center>
<form action="ratingsreturn.php" method=GET>
Ratings Search: <select name="rating"><option>G</option><option>PG</option>
on>PG-13</option><option>R</option><option>U</option></select>
<input type="submit" name="ratingsreturn" value="Search Ratings">
</form>
<center> or
<br></br>
</center>
<form action="genrereturn.php" method=GET>
Genre Search: <select name="genre"><option>Action</option><option>Anime</op
<option>Comedy</option><option>Disney</option><option>Drama</option><option
ly</option><option>Horror</option><option>Music</option><option>Mystery</op
<option>SciFi</option><option>Suspense</option></select>
<input type="submit" name="genrereturn" value="Search Genre">
</form>

<br>

        </body>
</html>

2. Title Return Page
<html>

        <head>
                <title>DVD Titles Search Results</title>
        </head>

<body>

     <tr>
     <td colspan="2" align="left">
     <table align="center" cellspacing="2" cellpadding="2" border="0" 
bgcolor="#234765">
     <tbody><tr><td bgcolor="#9a9aaa" align="center"><b>DVD Title Search 
Results</b></td></tr>
            <tr>
      <td valign="top">
      <table width="100%" border="0" bgcolor="#ffffff">
      <tbody><tr><td nowrap="nowrap" valign="top" bgcolor="#ffffff" 
align="left">


<?php
$_GET['$search'];
        echo "Titles Including : <b>".$search."</b><br>";
        $link = mysql_connect("Way.local", "search", "query");
   if (!$link) {
     die("Your database is screwed: " . mysql_error());
    }
        mysql_select_db("dvd");
        $query="SELECT * FROM dvd WHERE Title LIKE '%".$search."%' ORDER BY 
Title";
        $result=mysql_query($query, $link);
   if (!$result) {
     die("Your data is hosed: " .mysql_error());
    }
        while ($row=mysql_fetch_object($result)) {
            echo "-- ".$row->Title." -- ".$row->Year." -- ".$row->Length." -- 
".$row->Rating." -- ".$row->Genre."<br>";
    }

</html>

3. Ratings Return Page
<html>

        <head>
                <title>DVD Ratings Search Results</title>
        </head>

<body>

     <tr>
     <td colspan="2" align="left">
     <table align="center" cellspacing="2" cellpadding="2" border="0" 
bgcolor="#234765">
     <tbody><tr><td bgcolor="#9a9aaa" align="center"><b>DVD Ratings Search 
Results</b></td></tr>
            <tr>
      <td valign="top">
      <table width="100%" border="0" bgcolor="#ffffff">
      <tbody><tr><td nowrap="nowrap" valign="top" bgcolor="#ffffff" 
align="left">


<?php
$_GET['$rating'];
        echo "Titles Including : <b>".$rating."</b><br>";
        $link = mysql_connect("Way.local", "search", "query");
   if (!$link) {
     die("Your database is screwed: " . mysql_error());
    }
        mysql_select_db("dvd");
        $query="SELECT * FROM dvd WHERE Rating LIKE '".$rating."' ORDER BY 
Title";
        $result=mysql_query($query, $link);
   if (!$result) {
     die("Your data is hosed: " .mysql_error());
    }
        while ($row=mysql_fetch_object($result)) {
            echo "-- ".$row->Title." -- ".$row->Year." -- ".$row->Length." -- 
".$row->Rating." -- ".$row->Genre."<br>";
    }

</html>

4. Genre Return Page
<html>

        <head>
                <title>DVD Genre Search Results</title>
        </head>

<body>

     <tr>
     <td colspan="2" align="left">
     <table align="center" cellspacing="2" cellpadding="2" border="0" 
bgcolor="#234765">
     <tbody><tr><td bgcolor="#9a9aaa" align="center"><b>DVD Genre Search 
Results</b></td></tr>
            <tr>
      <td valign="top">
      <table width="100%" border="0" bgcolor="#ffffff">
      <tbody><tr><td nowrap="nowrap" valign="top" bgcolor="#ffffff" 
align="left">


<?php
$_GET['$genre'];
        echo "Titles In Genre : <b>".$genre."</b><br>";
        $link = mysql_connect("Way.local", "search", "query");
   if (!$link) {
     die("Your database is screwed: " . mysql_error());
    }
        mysql_select_db("dvd");
        $query="SELECT * FROM dvd WHERE Genre LIKE '%".$genre."%' ORDER BY 
Title";
        $result=mysql_query($query, $link);
   if (!$result) {
     die("Your data is hosed: " .mysql_error());
    }
        while ($row=mysql_fetch_object($result)) {
            echo "-- ".$row->Title." -- ".$row->Year." -- ".$row->Length." -- 
".$row->Rating."<br>";
    }

</html>


All that is different between this code for my linux box and my Mac is the 
database name (and of course the machines upon which the code is running).  
With this code the Title Return Page and the Genre Return Page both return 
all dvd titles.  The Ratings Return Page displays no results at all.  All the 
returned result, however, are "ORDERED BY Title".

Linux MySQL = 4.0.15
Mac MySQL = 4.0.18

Jon
Minding of Madness