php - mysql_num_rows always zero, despite of reality -


I have mySQL database installed, I have a "user" table and one line I to administer it with phpMyAdmin A test database is kept. In PhpMyAdmin, when I "select from users", then I'm getting a line right.

Now I have created a small PHP Hello World page. It connects to a very databases, I have opened a full privileged user credentials. It submits the same question, but for some weird reason, mysql_num_rows are always zero

Code has been used here. Please note that I am seeing the following debug messages on my web page when I load it:

  Success so far No line till  

this I am using the code:

  & lt ;? Php if (! $ Link = mysql_connect ('localhost', 'testuser', 'testpw')) {echo 'could not connect to mysql'; Go out; } If (! Mysql_select_db ('MYDB', $ link)) 'echo could not be selected'; Go out; } Echo 'success till now & lt; Br> & # 39; & # 39; $ Sql ​​= 'Select' from 'User'; $ Result = mysql_query ($ sql, $ link) or die (mysql_error ()); If (!! $ Result) {echo "DB error, could not query database \ n"; Echo 'mysql error:'. Mysql_error (); Go out; } Echo 'success till now 2 & lt; Br> & # 39; & # 39; $ Countt = mysql_num_rows ($ result); If ($ count> 0) {resonance "we have rows"; } And {resonant "any rows"; } While ($ line = mysql_fetch_assoc ($ result)) {echo $ row ['foo']; } Mysql_free_result ($ result); ? & Gt;  

I appreciate what I'm doing, as any wrong as possible. As you can tell - I am a PHP nube.

  $ countt  

/p>

  If ($ count> 0)  

is such that $ count is undefined

< / Html>

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -