graham23s Posted June 10, 2007 Share Posted June 10, 2007 Hi Guys, in my search function if a user searches for a file named: something.somethinelse.pdf the concatenation symbol seems to only allow the first word to be searched for, i was going to (if possible) use a reg expression to tell search to ignore the (.) is that possible at all? if (eregi('.', $keywords)) { echo "if the string contains a (.) what to do?"; } thanks guys Graham Quote Link to comment https://forums.phpfreaks.com/topic/54940-reg-expresion-help/ Share on other sites More sharing options...
chigley Posted June 10, 2007 Share Posted June 10, 2007 If your search code fails when it hits a period, you need to sort that out instead of finding a workaround! Paste your search code please Quote Link to comment https://forums.phpfreaks.com/topic/54940-reg-expresion-help/#findComment-271703 Share on other sites More sharing options...
graham23s Posted June 10, 2007 Author Share Posted June 10, 2007 Hi Chigley, no problem mate here it is: <?php // Check to see if there are submitted keywords.../////////////////////////////// if (isset($_GET["keywords"]) && ($_GET["keywords"] != "")) { // Require a database connection...////////////////////////////////////////////// require("includes/db_connection.php"); // Capture our search words and remove url encoding.../////////////////////////// $keywords = urldecode($_GET["keywords"]); // Create our query, including our keywords.../////////////////////////////////// $sql = "SELECT id,file_name,cat_id,description,date_added "; $sql .= "FROM `uploaded_files` "; $sql .= "WHERE `file_name` LIKE '%$keywords%' OR `description` LIKE '%$keywords%'"; $sql .= "ORDER BY `date_added` ASC "; // Create a result set from our query...///////////////////////////////////////// $rs = mysql_query($sql) or die(mysql_error()); // number of results...////////////////////////////////////////////////////////// $num_res = mysql_num_rows($rs); ?> thanks mate Graham Quote Link to comment https://forums.phpfreaks.com/topic/54940-reg-expresion-help/#findComment-271706 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.