mysql - PHP or SQL issue -


i'm having strange issue php code. code.

$c=mysqli_connect('localhost','root','*************'); $a=0; if($b=mysqli_num_rows(mysqli_query($c,$z="select count(*) `information_schema`.`tables` `table_schema` = 'wallets' , `table_name` = '".$_session['uname']."'"))!=0) {   print("<b>wallet found</b>$b - $z");   $a=1; } if(!$a) {   print("<b>no accounts found :(</b>"); } ?> 

this code returns this

wallet found1 - select count(*) `information_schema`.`tables` `table_schema` = 'wallets' , `table_name` = 'shadowri5ing' 

it should return this

no accounts found :( 

i enter same query in phpmyadmin , returns this

count(*) 0 

please me fix php code! thank :)

edit: issue solved doing this...

$q=mysqli_query($c,$z="select count(*) `information_schema`.`tables` `table_schema` = 'wallets' , `table_name` = '".$_session['uname']."'"); $row=mysqli_fetch_array($q); if($row['count(*)']) {   print("<b>wallet found</b> {$row['count(*)']} - $z - $a");   $a=1; } 

your query checking number of rows being returned. when select count(*) no aggregation, 1 row. value on row might 0, row.

you should either check value of what's being returned. or remove count() , return values each row found.

my suggestion change query to:

select 1 `information_schema`.`tables` `table_schema` = 'wallets' , `table_name` = '".$_session['uname']."' limit 1; 

if found, you'll 1 row back. if nothing, existing logic work.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -