Jump to content

Apache, PHP, mySQL form handling


mickisdaddy

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

Link to comment
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

Link to comment
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.