ctcp Posted August 30, 2011 Share Posted August 30, 2011 Hello i got this promblem if i search google i got result in my page if i type Google got nothink can sombady help me ? $colname_Recordset2 = "-1"; if (isset($_GET['first_name'])) { $colname_Recordset2 = $_GET['first_name']; } mysql_select_db($database_hlios, $hlios); $query_Recordset2 = sprintf("SELECT * FROM carpets WHERE first_name LIKE %s", GetSQLValueString("%" . $colname_Recordset2 . "%", "text")); $Recordset2 = mysql_query($query_Recordset2, $hlios) or die(mysql_error()); $row_Recordset2 = mysql_fetch_assoc($Recordset2); $totalRows_Recordset2 = mysql_num_rows($Recordset2); Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted August 30, 2011 Share Posted August 30, 2011 use strtolower Quote Link to comment Share on other sites More sharing options...
ctcp Posted August 30, 2011 Author Share Posted August 30, 2011 use strtolower how to use this in query? Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted August 30, 2011 Share Posted August 30, 2011 if (isset($_GET['first_name'])) { $colname_Recordset2 = strtolower($_GET['first_name']); } Quote Link to comment Share on other sites More sharing options...
ctcp Posted August 30, 2011 Author Share Posted August 30, 2011 if (isset($_GET['first_name'])) { $colname_Recordset2 = strtolower($_GET['first_name']); } Thank you for your help but this not work <?php $colname_Recordset2 = "-1"; if (isset($_GET['first_name'])) { $colname_Recordset2 = strtolower($_GET['first_name']); } mysql_select_db($database_hlios, $hlios); $query_Recordset2 = sprintf("SELECT * FROM carpets WHERE first_name LIKE %s", GetSQLValueString("%" . $colname_Recordset2 . "%", "text")); $Recordset2 = mysql_query($query_Recordset2, $hlios) or die(mysql_error()); $row_Recordset2 = mysql_fetch_assoc($Recordset2); $totalRows_Recordset2 = mysql_num_rows($Recordset2); ?> Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted August 30, 2011 Share Posted August 30, 2011 should.. any errors? Quote Link to comment Share on other sites More sharing options...
ctcp Posted August 30, 2011 Author Share Posted August 30, 2011 No error but not working got some promblem Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted August 30, 2011 Share Posted August 30, 2011 try outputting the strtolower($_GET['first_name']); to see what you are receiving Quote Link to comment Share on other sites More sharing options...
ctcp Posted August 30, 2011 Author Share Posted August 30, 2011 $colname_Recordset2 = "-1"; if (strtolower($_GET['first_name'])) { $colname_Recordset2 = strtolower($_GET['first_name']); } mysql_select_db($database_hlios, $hlios); $query_Recordset2 = sprintf("SELECT * FROM carpets WHERE first_name LIKE %s", GetSQLValueString("%" . $colname_Recordset2 . "%", "text")) ; $Recordset2 = mysql_query($query_Recordset2, $hlios) or die(mysql_error()); $row_Recordset2 = mysql_fetch_assoc($Recordset2); $totalRows_Recordset2 = mysql_num_rows($Recordset2); this is right? if (strtolower($_GET['first_name'])) { No errors but some promblem not wroking Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted August 30, 2011 Share Posted August 30, 2011 what i meant was this.. if (isset($_GET['first_name'])) { $colname_Recordset2 = strtolower($_GET['first_name']); print $colname_Recordset2; } Quote Link to comment Share on other sites More sharing options...
ctcp Posted August 30, 2011 Author Share Posted August 30, 2011 what i meant was this.. if (isset($_GET['first_name'])) { $colname_Recordset2 = strtolower($_GET['first_name']); print $colname_Recordset2; } if (isset($_GET['first_name'])) { $colname_Recordset2 = strtolower($_GET['first_name']); print $colname_Recordset2; } mysql_select_db($database_hlios, $hlios); $query_Recordset2 = sprintf ("SELECT * FROM carpets WHERE first_name LIKE %s", GetSQLValueString("%" . $colname_Recordset2 . "%", "text")) ; $Recordset2 = mysql_query($query_Recordset2, $hlios) or die(mysql_error()); $row_Recordset2 = mysql_fetch_assoc($Recordset2); $totalRows_Recordset2 = mysql_num_rows($Recordset2); No errors but not working got some promblem. Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted August 30, 2011 Share Posted August 30, 2011 WHAT DOES IT OUPUT TO THE BROWSER? if you type in Google.. you should receive google in the browser Quote Link to comment Share on other sites More sharing options...
ctcp Posted August 30, 2011 Author Share Posted August 30, 2011 if i type Google got google if i type google got google Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted August 30, 2011 Share Posted August 30, 2011 so that should solve your issue then.. if you are searching for lowercase field values.. Quote Link to comment Share on other sites More sharing options...
ctcp Posted August 30, 2011 Author Share Posted August 30, 2011 Nope how to search together in my database i got name Google if i type google got nothink in results . Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted August 30, 2011 Share Posted August 30, 2011 so you have the opposite problem of what you stated in your original post... great.. then use this instead.. if (isset($_GET['first_name'])) { $colname_Recordset2 = ucfirst(strtolower($_GET['first_name'])); } Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted August 30, 2011 Share Posted August 30, 2011 You're converting the string to compare to lowercase, but not the value in the database. You need to either use a case insensitive collation or compare the values with both of them converted to the same case. http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html $term = strtolower('Google'); $query = "SELECT field FROM table WHERE LOWER(field) LIKE '%$term%'"; Quote Link to comment Share on other sites More sharing options...
ctcp Posted August 30, 2011 Author Share Posted August 30, 2011 You're converting the string to compare to lowercase, but not the value in the database. You need to either use a case insensitive collation or compare the values with both of them converted to the same case. http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html $term = strtolower('Google'); $query = "SELECT field FROM table WHERE LOWER(field) LIKE '%$term%'"; thank you for your post but how to? in my code Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted August 30, 2011 Share Posted August 30, 2011 You're converting the string to compare to lowercase, but not the value in the database. You need to either use a case insensitive collation or compare the values with both of them converted to the same case. http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html $term = strtolower('Google'); $query = "SELECT field FROM table WHERE LOWER(field) LIKE '%$term%'"; thank you for your post but how to? in my code can't get any simpler of an example then what he showed you..or you can use what I suggested if you have the first letter capitalized.. however for consistency, i would go with pikachus method Quote Link to comment Share on other sites More sharing options...
ctcp Posted August 30, 2011 Author Share Posted August 30, 2011 AyKay47 many thanks for your time Im sorry this is right ? couse i got error message .. <?php $colname_Recordset2 = "-1"; if (isset($_GET['first_name'])) { $colname_Recordset2 = $_GET['first_name']; } $term = strtolower($colname_Recordset2); mysql_select_db($database_hlios, $hlios); $query_Recordset2 = sprintf("SELECT * FROM carpets WHERE LOWER(first_name) LIKE '%$term%'", GetSQLValueString("%" . $colname_Recordset2 . "%", "text")); $Recordset2 = mysql_query($query_Recordset2, $hlios) or die(mysql_error()); $row_Recordset2 = mysql_fetch_assoc($Recordset2); $totalRows_Recordset2 = mysql_num_rows($Recordset2); ?> Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted August 30, 2011 Share Posted August 30, 2011 <?php $colname_Recordset2 = "-1"; if (isset($_GET['first_name'])) { $colname_Recordset2 = strtolower($_GET['first_name']); //add strtolower here } $term = strtolower($colname_Recordset2); mysql_select_db($database_hlios, $hlios); $query_Recordset2 = sprintf("SELECT * FROM carpets WHERE LOWER(first_name) LIKE '%$term%'", GetSQLValueString("%" . $colname_Recordset2 . "%", "text")); $Recordset2 = mysql_query($query_Recordset2, $hlios) or die(mysql_error()); $row_Recordset2 = mysql_fetch_assoc($Recordset2); $totalRows_Recordset2 = mysql_num_rows($Recordset2); ?> Quote Link to comment Share on other sites More sharing options...
ctcp Posted August 30, 2011 Author Share Posted August 30, 2011 Warning: sprintf() [function.sprintf]: Too few arguments in /helper.php(487) : eval()'d code on line 49 Query was empty <?php $colname_Recordset2 = "-1"; if (isset($_GET['first_name'])) { $colname_Recordset2 = strtolower($_GET['first_name']); //add strtolower here } $term = strtolower($colname_Recordset2); // <---------------line 49 mysql_select_db($database_hlios, $hlios); $query_Recordset2 = sprintf("SELECT * FROM carpets WHERE LOWER(first_name) LIKE '%$term%'", GetSQLValueString("%" . $colname_Recordset2 . "%", "text")); $Recordset2 = mysql_query($query_Recordset2, $hlios) or die(mysql_error()); $row_Recordset2 = mysql_fetch_assoc($Recordset2); $totalRows_Recordset2 = mysql_num_rows($Recordset2); ?> Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted August 30, 2011 Share Posted August 30, 2011 you should be placing your query inside of your if condition.. Quote Link to comment Share on other sites More sharing options...
fenway Posted September 1, 2011 Share Posted September 1, 2011 This has to stop -- php syntax errors have no place on this forum, especially not one at a time. Post your CREATE TABLE so we can see what collation you're using. Quote Link to comment 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.