Jump to content

Sql LIKE problem


Tenaciousmug

Recommended Posts

$sql = "SELECT softwareID,softwareName,softwareType,softwareDesc,softwarePath,ITOnly FROM software WHERE softwareName LIKE '%($searchSoftware)%' ORBER BY softwareName";
$result = mysqli_query($cxn,$sql) or die(mysqli_error());

 

There is something wrong with my LIKE statement because it's not pulling it since I'm either formatting it wrong or something.

Can anyone catch it?

Link to comment
https://forums.phpfreaks.com/topic/255066-sql-like-problem/
Share on other sites

a wild guess, but try removing the parens surrounding the LIKE

 

No, that's not it. You need to use curly braces {} around the variable $searchSoftware, NOT parens ()

 

$sql = "SELECT softwareID, softwareName, softwareType, softwareDesc, softwarePath, ITOnly
        FROM software
        WHERE softwareName LIKE '%{$searchSoftware}%'
        ORBER BY softwareName";
$result = mysqli_query($cxn, $sql) or die(mysqli_error());

Link to comment
https://forums.phpfreaks.com/topic/255066-sql-like-problem/#findComment-1307875
Share on other sites

Ah it's still not working, but I did fix that.

[15-Jan-2012 12:13:03] PHP Warning:  mysqli_error() expects exactly 1 parameter, 0 given in /home1/elvonica/public_html/intellectproductions/james/search_software.php on line 13

 

Which is where the result variable is. So it's not returning anything, but when I put that in the sql statement in the phpmyadmin, it gives me the result I want. Of course, I change the LIKE '%{$searchSoftware}%' to LIKE '%hatch%'.

 

EDIT

Nvm. I'm dumb. xD I spelled ORDER BY wrong. Thank you!!!!

Link to comment
https://forums.phpfreaks.com/topic/255066-sql-like-problem/#findComment-1307882
Share on other sites

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.