Jump to content


Photo

Apache, PHP, mySQL form handling


  • Please log in to reply
6 replies to this topic

#1 mickisdaddy

mickisdaddy
  • Members
  • Pip
  • Newbie
  • 5 posts
  • LocationColorado

Posted 10 January 2003 - 06:14 AM

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

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 10 January 2003 - 06:34 AM

if the code works fine, the problem sounds like your php error reporting it set too high ( notifying you of code that isn\'t 100% perfect, but still functions fine )

check the error_reporting line in your php.ini and also look into register_globals

http://www.php.net/m...sterglobals.php
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#3 mickisdaddy

mickisdaddy
  • Members
  • Pip
  • Newbie
  • 5 posts
  • LocationColorado

Posted 10 January 2003 - 05:45 PM

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

#4 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 10 January 2003 - 06:57 PM

on your computer — what does the error_reporting line say in the php.ini ?
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#5 mickisdaddy

mickisdaddy
  • Members
  • Pip
  • Newbie
  • 5 posts
  • LocationColorado

Posted 10 January 2003 - 09:11 PM

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

#6 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 11 January 2003 - 05:15 AM

can you post the code? sounds like the query is not being constructed correctly.
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#7 mickisdaddy

mickisdaddy
  • Members
  • Pip
  • Newbie
  • 5 posts
  • LocationColorado

Posted 13 January 2003 - 05:33 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users