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