After spending a few hours trying every syntax in my books and a few from on-line, I still can't get a form to pass a field value to the WHERE clause in a mySQL query that is part of a PHP script.
First, to debug everything else in the script, I hardcode a known value (DOE, JOHN) in the PHP/mySQL WHERE clause.
WHERE a.name = "DOE, JOHN"
The submit button uses the form action to call the PHP script and returns the values I want (DOE, JOHN, 2001, DOE, JOHN, 2002, etc.) formated with "while ($line = mysql_fetch_array($result, MYSQL_ASSOC))" etc.
With the problem narrowed down to passing the value, I enter DOE, JOHN in the form but I get either an empty result or a parsing error, depending on what I tried. But nothing I have tried as a value definition in the form has worked in any combination with declarations in the php script to put the form value in the WHERE clause and return results:
value="name"
or
value=<?php echo $_POST['name']; ?>
and in the where clause:
$name = 'name';
where a.username="$name"
or
$name = $_POST['name'];
where a.username="$name"
or
$name = $_POST['name'];
where a.username="{$name}"
or
$name = "name";
where a.username="{$name}"
or
where a.username={$_POST['name']}
or any of umpteen dozen other variations from the book or from wild guesses.
I also tried initializing the value, but to no avail:
$name = $_POST['name'];
This can't be as hard as I'm making it. I have run other scripts that update databases from form fields, and tried syntax from those scripts to no avail. Anybody have any advice?