$authorf is empty, I guess register_globals is off, you should use
"select * from complete where authorf = '$_POST[authorf]'"
or
"select * from complete where authorf = '$_GET[authorf]'"
depending if you use get or post variable.

P M wrote:

Hi all!

I'm having trouble retrieving a selection of my database contents. The problem is when I search for entries that exactly match a search criteria, see below:

(database connection established successfully here..)

$result = mysql_query("select * from complete where authorf = '$authorf'");

  if ( $r = mysql_fetch_array($result) )
  {
   echo "Found entries:<ul>";
   echo "<table border=1>";

   do
   {
    print "<tr><td>";
    print $r["authorf"];
    print "</td><td>";
    print $r["authorl"];
    print "</td><td>";
    print $r["title"];
    print "</td></tr>";
   } while ($r = mysql_fetch_array($result));

   echo "</table>";
   mysql_free_result($result);
  }

Now, I know for sure that there's nothing wrong with the code within the do-loop, because if I change the SQL query to the following:

$result = mysql_query("select * from complete");

..I will get all entries from the database, nicely output to the page.

(QUESTION 1)
So what is wrong here? I've tried playing with the single quotation marks (') as well 
as using the LIKE parameter with the SELECT statement, but nothing turns out to work. 
See below for an example of the latter..

$result = mysql_query("select * from complete where authorf like '$authorf%'");

This returns all table entries, just as the previous example. Perhaps there is something about the '%' sign but I have no good reference available.. :-/

I also had an idea about the HTML form item names (such as text boxes) being required to be named as the column names in the MySQL table, but that failed miserably also (this is what I used in the examples below - substituting form item names doesn't change anything..)

Now I'm sure that the error is a simple one, which tends to be make me even more frustrated (I¨m practically bald now from tearing my tufts of hair all night long :-) ). Thanks for any input here!

(QUESTION 2)
Also, another question relevant to PHP/SQL RDBMS's interfacing: Does anyoone know 
where I can find thorough documents on PHP commands for this purpose? Some texts which 
tangents database modelling and optimization would be optimal, since I'm interested in 
those areas also!
Due to my current location in the Balkans with a crappy modem connection and a bad 
selection of book stores I'd prefer online texts, but any tips are welcome! Thanks in 
advance!

Video Populares et Optimates




-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to