Undefined Variables

Codes here !

Moderators: macek, egami, gesf

da9nlc
New php-forum User
New php-forum User
Posts: 21
Joined: Sun Feb 23, 2003 11:58 pm
Contact:

Undefined Variables

Postby da9nlc » Mon Feb 24, 2003 12:34 am

I have been following Sam's Php + Mysql web developement book.

Having written out the script the way the book has them:

trim($searchterm);
if(!searchtype || !searchterm)

When I ran the script I got the error undefined variables.

Having sifted through various sites and tutorials I found one that showed me the following I have adapted to suit:

trim($_POST['searchterm']);
if(empty($_POST['searchtype']) || empty($_POST['searchterm']));

I now recieve no error message so I believe it is being parsed. However, that is as far as the script runs, receiveing the message "You have not entered details. Please return to form."

I have checked the form and can see no problem there all layed out as stated in the book (not that this is much comfort seeing as most scripts dont work or are non globals off compliant).

Has anyone else had these particular problems and can anybody tell me why is the variables not being passed from the form.

Thank you

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Mon Feb 24, 2003 1:55 am

1st page -> form
2nd page -> your script

might be...

User avatar
pootergeist
New php-forum User
New php-forum User
Posts: 191
Joined: Wed Jan 29, 2003 7:11 am
Location: UK
Contact:

Postby pootergeist » Mon Feb 24, 2003 4:42 am

try echoing the variables prior to any if clauses (which shouldn't have ; after them)

echo $_POST['searchterm'];
if(isset($_POST['searchterm']))
{
// stuff

User avatar
Redcircle
Moderator
Moderator
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Postby Redcircle » Mon Feb 24, 2003 5:52 am

as you read in this post http://www.php-forum.com/p/viewtopic.php?t=1483 your book should be burned.

please post more code.

da9nlc
New php-forum User
New php-forum User
Posts: 21
Joined: Sun Feb 23, 2003 11:58 pm
Contact:

Thank guys

Postby da9nlc » Mon Feb 24, 2003 3:24 pm

Having read all your responses I have found useful and got through the rest of the script ok.

Even the guy who thinks he's god or maybe doesnt I guess you were pushing me towards the include_once function thanks.

At the same time as buying Sams php web development I bought their Developer Cookbook is this a waste of money too or could I possibly find that more useful

Thanks


Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 1 guest