Jump to content

Archived

This topic is now archived and is closed to further replies.

mickisdaddy

Apache, PHP, mySQL form handling

Recommended Posts

Hello all

 

I am having a little problem.

 

I am setting up a test server on my computer at home to test my web site before I make it live. I finally got Apache, PHP and mySQL all installed.

 

I have a form that searches my database. When I click search it goes to the results page and says the following:

 

Notice: Undefined variable: last in c:program filesapache groupapachehtdocsscswwwbaseballplayers.php on line 82

 

Notice: Undefined variable: first in c:program filesapache groupapachehtdocsscswwwbaseballplayers.php on line 82

 

These are the two variables that are passed from the form. This page works with no problems on my hosts server.

 

I do have phpMyAdmin installed and working perfectly.

 

What am I doing wrong? Is there something more that I have to install? Is there something in the httpd.conf file I have to change?

 

Here is my config

OS WinXP Pro

Apache 1.3.27

PHP 4.3.0

mySQL 3.23.49

phpMyAdmin 2.2.6

 

Any help is greatly apreciated.

 

Sean Wilhelm

Share this post


Link to post
Share on other sites

The code only works fine on my hosts server not on my test server.

 

On my test server I get those messages then it lists all lines from that table of the database.

 

Sean

Share this post


Link to post
Share on other sites

on your computer — what does the error_reporting line say in the php.ini ?

Share this post


Link to post
Share on other sites

These are the lines that are not commented out

 

error_reporting = E_ALL; display all errors, warnings and notices

display_errors = On

display_startup_errors = Off

log_errors = Off

track_errors = Off

 

I changed the error_reporting to E_ERROR and it gets rid of the errors about the undefined variable, but with the results I still have the same problem.

 

The form searches by first and last name. I enter a last name to search for and the results page gives me all people no matter what name they are.

 

I think it is a problem with processing the variables that are passed from the form.

 

Sean

Share this post


Link to post
Share on other sites

can you post the code? sounds like the query is not being constructed correctly.

Share this post


Link to post
Share on other sites

Here is the form code

 

<form method=\"post\" action=\"Baseball/players.php\">

<p>Last Name

<input type=\"text\" name=\"last\">

<br>

First Name

<input type=\"text\" name=\"first\">

<br>

<input type=\"submit\" name=\"Submit\" value=\"Submit\">

<input type=\"reset\" name=\"Submit2\" value=\"Reset\">

 

Then it goes to this results page

 

<?php

 

$db = mysql_connect(\"localhost\", \"login\", \"password\");

 

mysql_select_db(\"database\",$db);

 

$result = mysql_query(\"SELECT player_id, first_name, last_name FROM players WHERE last_name LIKE \'$last%\' AND first_name LIKE \'$first%\'\", $db);

 

echo \"<b>Here are the players that match your entry</b><p>\";

 

while ($myrow = mysql_fetch_row($result)) {

 

printf(\"<a href=\'Baseball/dbtest.php3?player_id=%s&fname=%s&lname=%s\'>%s %s</a><br>\", $myrow[0], $myrow[1], $myrow[2], $myrow[1], $myrow[2]);

 

}

mysql_close($db);

 

?>

 

 

I turned the error handling down a little and it got rid of the error, but it still gave me results of all records in the table that I am querying.

 

The same file with no modifications works on my hosts server. It then gives me this problem on the test server on my computer that I am trying to get working.

 

Sean

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.