Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Undefined Variables

Codes here !

Moderators: macek, egami, gesf

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:

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:

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
New php-forum User
New php-forum User
Posts: 21
Joined: Sun Feb 23, 2003 11:58 pm

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

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

might be...
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

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'];
// stuff
New php-forum User
New php-forum User
Posts: 191
Joined: Wed Jan 29, 2003 7:11 am
Location: UK

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

as you read in this post your book should be burned.

please post more code.
User avatar
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

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

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

Return to mySQL & php coding

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.