Jump to content

php mysql search how to upper ?


ctcp

Recommended Posts

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);

Link to comment
https://forums.phpfreaks.com/topic/246028-php-mysql-search-how-to-upper/
Share on other sites

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);

?>

 

$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 :(

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.

 

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%'";

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

 

 

 

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

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);
?>


<?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);
?>

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);
?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.