-1

can anyone see why this statement is not working? im attempting to select all except the value in $creator, I know the value is set because a echo statement just below the query reveals the value,

$this->res = mysqli_query($con,"SELECT * FROM escrow WHERE name !=$creator  "); 

Ive discovered that this works:
$this->res = mysql_query("SELECT * FROM challenges_created WHERE name !='$creator'");

but this is not working: $this->res = mysqli_query($conn,"SELECT * FROM challenges_created WHERE name !='$creator'");

obviously the syntax is wrong somewhere in the latter of the 2

  • 1
    Define "isn't working"? For mysqli debugging tips, see http://stackoverflow.com/questions/2552545/mysqli-prepared-statements-error-reporting What type is `name`? If it's a varchar, you may be missing quotes. – Pekka Oct 25 '15 at 21:05
  • the query does not do what im asking it to do, which is extract all from a table except where name is the variable, the variable is a name under a name column in a MySQL table – user5420896 Oct 25 '15 at 21:15
  • What *does* it do then? – Pekka Oct 25 '15 at 21:25
  • it does nothing, does the query look correct? – user5420896 Oct 25 '15 at 21:29
  • Impossible to tell - but you can have mysqli tell you *yourself* what is wrong here by using proper error reporting. Check out the link above – Pekka Oct 25 '15 at 21:39
  • `$this->res = mysqli_query($con,"SELECT * FROM escrow WHERE name !='$creator' ");` – Akshay Oct 25 '15 at 22:08
  • 1
    Not knowing your table structure, I am going to make a strong guess that `$creator` contains a _string_ value, which must be single quoted in a SQL statement. See [When to use single quotes, double quotes, backticks](http://stackoverflow.com/a/11321508/541091) for examples. And if the value `$creator` originates from user input, you should be using [`prepare()/bind_param()/execute()`](http://php.net/manual/en/mysqli.prepare.php) instead of passing the variable into the query. – Michael Berkowski Oct 25 '15 at 22:08

1 Answers1

1

Try this:-

$this->res = mysqli_query($con,"SELECT * FROM escrow WHERE name !='$creator'");        
Sam Smith
  • 21
  • 2