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

?>

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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


Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.