Jump to content

Recommended Posts

Now I fully understand why everyone hates Internet Explorer.  I'm still learning how to code in PHP, but I have a pretty good grasp on SQL.  I never really liked using it, but never totally understood what a pain it was.  I have a simple search text box that I use to query a one table database.  Nothing complicated.  It works like a charm in both Firefox and Chrome.  When I fire it up in IE however, it doesn't display anything.  I'm completely stumped, it's not like I'm doing anything too complex.  I'm hoping someone has time to take a quick peak at my code and let me know what I might be missing...thanks in advance!

 

<?php
DEFINE ('DB_USER', 'db_user');
DEFINE ('DB_PASSWORD', 'pass'); 
DEFINE ('DB_HOST', 'localhost'); 
DEFINE ('DB_NAME', 'db_name'); 
$dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error());
@mysql_select_db (DB_NAME) OR die('Could not select the database: ' . mysql_error() );
if(isset($_POST['submit'])){ //if the form was submited
$search = $_POST['search']; //put in $search what the user entered 
if(trim($search) == ''){ //if the user didn't type a keyword
	$errors = '<font color="red">Please enter a keyword</font><br /><br />';
}
if($errors == ''){ //if we don't have any errors 
                       // $search holds what the user typed
	$query = "SELECT * from opportunities WHERE opp_title LIKE '%$search%' OR opp_desc LIKE '%$search%' OR opp_location_name LIKE '%$search%' OR opp_startdate LIKE '%$search%' OR opp_enddate LIKE '%$search$'"; 
	$result = mysql_query($query);
	if($result){
		display_form();//redisplay the search box
		echo "<script src='http://status1.org/magpierss/sorttable.js'></script>";
		echo "<h1>found ". mysql_num_rows($result)." results</h1>";
		echo "<font size='1'>Click the column headings to sort...</font>";
		echo "<table border='1' class='sortable'>";
		echo "<tr><th>Title</th><th>Location</th><th>Description</th><th>Start Date</th><th>End Date</th></tr>";
		while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
			$mess=$row['post'];
			//$view = 'page.php?id='.row['id'];

			echo "<tr><td><a href=".$row['opp_link']." target=__blank>".$row['opp_title']."</a></td><td>".$row['opp_location_name']."</td><td>".$row['opp_desc']."</td><td>".$row['opp_startdate']."</td><td>".$row['opp_enddate']."</td></tr>";

		}
		echo "</table>";
	}
}
}

if(!isset($_POST['submit']) || $errors != ''){ 
  echo $errors;
  display_form();//display first time the search box
}


function display_form(){
    ?>

    <form id="search" action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
    Keyword: <input type="text" name="search" size="30" class="text"  /><br />
    <input type="submit" name="submit" value="Search" />
    </form>
    <?php
    }   
function snippet($text, $chars, $dots = false)
{
		$end_char = substr($text, $chars, 1);
        if(preg_match('#S#', $end_char))
        {
            $chars += strpos($text, ' ', $chars) - $chars;
        }
        $ret = ($dots) ? substr($text, 0, $chars) . '...' : substr($text, 0, $chars);
        return $ret ;
     } 
?>

Link to comment
https://forums.phpfreaks.com/topic/181544-phpmysql-search-not-working-in-ie/
Share on other sites

border-line need a sticky on this topic these days.

 

when you click the "Search" button with your mouse in IE, it works, correct?  but when you just hit "ENTER" it doesn't work, correct?

 

there's an issue with IE where it doesn't pass the value of a submit button when there is only one input field.

 

add this to the form:

 

<!--[if IE]><input type="text" style="display: none;" disabled="disabled" size="1" value="Ignore field. IE bug fix" /><![endif]-->

 

- OR -

 

you can change: if (isset ($_POST['submit'])) to if (isset ($_POST['search'])) and that would also work.

 

hope that helps.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.