Re: PHP Newbee Question
| From: | Bogdan Stancescu | Date: | Tue, 02 Jul 2002 14:41:42 +0000 |
| Subject: | Re: PHP Newbee Question | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-20268@lists.php.net to get a copy of this message | ||
It was fine this time! Your first message was addressed to <<php-db@lists.php.net>> instead of simply php-db@lists.php.net.
Well, make sure you don't use POST in the form and GET in the PHP - or vice-versa. Also, try replacing your debug code in the PHP with something like this:
------
echo ("<b>Debug:</b><p>\n");
echo("First: ".$_POST["first"]."; Last: ".$_POST["last"]."<br>\n");
echo("<hr>\n");
------
This way you can fiddle with a single line of code until you get it working, instead of risking to make a mistake either when testing or when printing.
Bogdan
Jeffrey Norsworthy wrote:
Thanks for the tip. Unfortunately it didn't fix the issue. I am sorry about the way the address message is displayed. There unfortunately isn't anything I can do about it. Jeffrey Norsworthy MCP, CCNA Network Administrator Community Health Services norswj@chsmaine.org <mailto:norswj@chsmaine.org>Mail scanat cu RAV Antivirus!Variable names are case-sensitive in PHP - try $HTTP_POST_VARS["first"] - or, for new versions of PHP, $_POST["first"]. In another train of thoughts, please use the proper e-mail address - I'm sure I'm not the only one using filters to automatically move mail to folders and your although probably valid according to the RFC, the way you formatted the php list e-mail address doesn't match the filter names... Thanks! Bogdan Jeffrey Norsworthy wrote: Hello All, I am new to PHP, and I am trying to design what I thought would be a fairly simple form, that queries a MYSQL database for two fields, (first, and last name). It should then return the entire results of the entry in the table. This part is actually 5 fields. If I run the script with static entries for "first", and "last", the process work flawlessly (as it should). If I try using variables for the search values, I do not receive any results. I have tried changing the form method from post, to get, and the problem continues. Any help would be greatly appreciated. Thank you. The first grouping is the html form, the second set is the php form that actually performs the search. Also the username, and password are populated in the actual script, I just took them out for the email. Thanks again. <html> <head><title>Contact lookup form</title></head> <body> <form action="test.php" method="post"> First Name: <input type="text" name="first"><br> Last Name: <input type="text" name="last"><br> <input type="submit" value="lookup"> </form> </body> </html> <?php define ('mysql_host', 'localhost'); define ('mysql_user', ''); define ('mysql_pass', ''); define ('mysql_db', 'chs'); if (! mysql_connect(mysql_host, mysql_user, mysql_pass) ) { die('Failed to connect to host " ' . mysql_host . ' " . '); } else { echo '' . mysql_host . '<br>'; } mysql_select_db(mysql_db); if ($http_get_vars['first'] && $http_get_vars['last']) { echo $http_get_vars['first'] . ' ' . $http_get_vars['last'] . '<br>'; } $result=mysql_query("select * from chs where first='$first' or last='$last'"); echo "<h2 align='center'>Results</h2>"; while ($row = mysql_fetch_array($result)) {Bogdan Stancescu <mgv@canad.ro> 07/02/02 10:15AM >>>echo "<b>{$row['first']} {$row['last']}   {$row['branch']}   {$row['extension']}   {$row['voice_mail']}   {$row['position']}</b> <br>"; } ?> Jeffrey Norsworthy MCP, CCNA Network Administrator Community Health Services norswj@chsmaine.org Mail scanat cu RAV Antivirus! -- PHP Database Mailing List (http://www.php.net/) <http://www.php.net/%29> To unsubscribe, visit: http://www.php.net/unsub.php