Re: Troubleshooting First Script

From: Date: Thu, 29 Jun 2000 11:46:11 +0000
Subject: Re: Troubleshooting First Script
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-3773@lists.php.net to get a copy of this message
Ben, Basically, your trouble is that you are trying to access variables are out of scope. In your functions you should have: function Find_a_Horse () { global $color, $gender, ......etc The function thinks that these are local to the funtion and sets them to blank. You need to tell the function to inherit the variables from the caller stack. Hope this helps, David. > Hi; > Upon selection of the fields and submission of the form, my script doesn't > return anything but the header: *Here's Your Horses!* This is true even > when *nothing* is selected and the default should say, in essence, select > something! Would someone please take a look at my code and see what I'm > doing wrong? A few periods *.* have been thrown in so (hopefully!) it > doesn't try to render itself in anyone's email client. > > function Find_a_Horse () { > > echo "<CENTER><H2>Here's Your > Horses!</CENTER></H2><P>"; > if ($color != 9 && $gender !=9 && $age != 9) { // *9* is default value > $query = "select name, color, gender, birth from horse order by color"; > /* CAN I ORDER BY MORE THAN ONE? */ > $result = mysql_query ($query) > or die ("Query failed"); > while ($row = mysql_fetch_row ($result))

« previous php.general (#3773) next »