php - SELECT query returns warning (expects parameter 1 to be resource) -


edit: (especially @marty mcvry). i've edited question.

table : purchase

 purchase_id     |   seller       |   buyer         12       |      2         |     5         29       |      5         |     2    $check=query("select (count(*) >= 2) result    purchase      inner join purchase b      on a.seller = b.buyer ,         a.buyer = b.seller   (a.seller = 2 , a.buyer = 5) or         (a.seller = 5 , a.buyer = 2)");   $row = mysql_fetch_row($check);  echo $row[0];  if ($row[0] > 0) {  foo  } else {  bar  }       

when run query, following error:

warning: mysql_fetch_row() expects parameter 1 resource, string given in line 180 (which $row = mysql_fetch_row($check);).

what going here?

fiy, here, query() connects db , executes sql statement, possibly parameters.

after edit:

as side note: query db correctly, although might want pdo or mysqli.

the problem resultset afterwards.

you have fetch row view result:

$row = mysql_fetch_row($check); echo $row[0]; if ($row[0] > 0) {     // code goes here } else {     // other code goes here } 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -