PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
if (isset($_REQUEST['yes']))
{
echo $_REQUEST['yes'];
if ($_REQUEST['yes']=="yes")
{
$part=$_POST['part'];
$desc=$_POST['desc'];
echo $part;
echo $desc;
if (isset($desc) AND empty($part))
{
$sql="SELECT * FROM parts WHERE description LIKE '%".$desc."%'";
$query=mysql_query($sql) or die(mysql_error());
while ($test=mysql_fetch_object($query))
{
$display="<b>Go Kart Model: $test->gk_model </b><br />";
$display .= "Part Number: $test->part_number<br />";
$display .= "Image: <img src='images/parts/".$test->part_number.".jpg'";
$display .= "Description: $test->description";
}
}
else if (isset($part) AND empty($desc))
{
$sql="SELECT * FROM parts WHERE part_number LIKE '%".$part."%'";
echo $sql;
$query=mysql_query($sql) or die(mysql_error());
while ($test=mysql_fetch_object($query))
{
$display="<b>Go Kart Model: $test->gk_model </b><br />";
$display .= "Part Number: $test->part_number<br />";
$display .= "Image: <img src='images/parts/".$test->part_number.".jpg'";
$display .= "Description: $test->description";
}
}
else if(empty($desc) AND empty($part))
{
$display="You must enter something.";
}
else {
$display=" You must enter one or the other, not both. Sorry";
}
}
}
echo "Feel free to search by part number or part description. If your first
search does not return any results try making your search terms a bit broader.<br />";
echo "<form action='index.php?page=search&yes=yes' method='POST'>
Part Number: <input type='text' name='part'></input><Br />
Description: <input type='text' name='desc'></input><br />
<input type='submit'></input>";
echo "<br />";
if (isset($display))
{
echo "$display";
}
yes i realize it has no input sanitization but that's not the issue. when i submit the form none of the error check i put in get's echoed and for that matter the form doesn't display either.what the hell am i missing?
does it go anywhere? have you tried doing echo 'here'; at different places to try to see what happens? also, you are still using $_REQUEST??? use $_GET instead.
yeah.i've tried echoing variables, tried echoing constants....nothing....not a damn thing..once i hit that form submission the page is gone....btw, the page is on index.php?page=search, i want the form to be on index.php?page=search&yes=yes, so it should work..yet..life hates me..
hummm i dont see anything wrong but I have never seen the use of the constant "AND" like you are using it. try replacing that with && - I dont know if that will do anything but maybe?
yep, display errors is on and error reporting is set to all and FYI in PHP you can use AND, part of the loosely typed jazz;) I do it if I am being to lazy to hit shift..and since I was in a hurry..no shift grrr..going to eat this code and re-write it all..
nope.nothing in the error logs last error was when I couldn't type in a page name, addkarts != addkart. doh. hehe. I'll let you know if I figure out something.
here's one to boggle your noggin! check this out..absolutely amazing..if I type in index.php?page=search&yes=yes right off it shows everything. however if I hit that submit button the world goes to hades! the hell?!!!
allow me to rephrase..i'm using includes to construct my page layout... it loads up the header, navigation,fotter, it's just the content doesn't load.lemme try commenting out stuff...
edit: this still didn't fire off..don't think it's an infinite loop...
if (isset($_REQUEST['yes']))
{
if ($_REQUEST['yes']=="yes")
{
$part=$_POST['part'];
$desc=$_POST['desc'];
/*if (isset($desc) AND empty($part))
{
$sql="SELECT * FROM parts WHERE description LIKE '%".$desc."%'";
$query=mysql_query($sql) or die(mysql_error());
while ($test=mysql_fetch_object($query))
{
$display="<b>Go Kart Model: $test->gk_model </b><br />";
$display .= "Part Number: $test->part_number<br />";
$display .= "Image: <img src='images/parts/".$test->part_number.".jpg'";
$display .= "Description: $test->description";
}
}
else if (isset($part) AND empty($desc))
{
$sql="SELECT * FROM parts WHERE part_number LIKE '%".$part."%'";
echo $sql;
$query=mysql_query($sql) or die(mysql_error());
while ($test=mysql_fetch_object($query))
{
$display="<b>Go Kart Model: $test->gk_model </b><br />";
$display .= "Part Number: $test->part_number<br />";
$display .= "Image: <img src='images/parts/".$test->part_number.".jpg'";
$display .= "Description: $test->description";
}
}
*/
if(empty($desc) AND empty($part))
{
$display="You must enter something.";
}
else {
$display=" You must enter one or the other, not both. Sorry";
}
}
}
I FIGURED IT OUT! hehe. On a previous page request finally shot me in the foot... i used $_REQUEST['part'] for a get variable ande then here I had a post part on the same page due to the nature of the include system so when i had both page=search and the part variable set the system didn't know which page to include and we end up with a blank page. be careful kiddies when doing includes.
No, be careful when using $_REQUEST. You should know exactly where your data is coming from, and if there are several possibilities, it is ideal to encapsulate the possibilities into a function to sort the mess out.