| | |
test mysql query for no results
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Aug 2006
Posts: 138
Reputation:
Solved Threads: 2
php Syntax (Toggle Plain Text)
if(mysql_num_rows($result)==0){ //do this }
Last edited by php_daemon; Jan 28th, 2007 at 6:21 pm.
Thanks, that was perfect.
•
•
Join Date: Mar 2008
Posts: 3
Reputation:
Solved Threads: 0
OMG, you helped me so much!! I am new to php, and I was tearing my hair out. Thank you, Thankyou,! You are my hero!!!!!
•
•
Join Date: Mar 2009
Posts: 4
Reputation:
Solved Threads: 0
Will this work for odbc_num_rows also. I tried but I get the same message no matter what
sql Syntax (Toggle Plain Text)
$sql="SELECT * FROM rac_master WHERE mrnumb='$mrnumb' AND racnumb='$racnumb' AND findetdate IS NULL"; $resultx=odbc_exec($conna,$sql); if (odbc_num_rows($resultx)==0) { echo"Record Has Been Finalized"; } odbc_close($conna);
Last edited by peter_budo; Mar 8th, 2009 at 7:03 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
•
•
Join Date: Mar 2009
Posts: 4
Reputation:
Solved Threads: 0
Turns out the
Example:
odbc_num_rows will always return -1 when using MSSQL. I changed my connecton to mssql_connect and mssql_num_rows . Every thing is working fine now.Example:
PHP Syntax (Toggle Plain Text)
$conn=mssql_connect('localhost','******','******'); $msdb=mssql_select_db("DatabaseName",$conn); $sql="SELECT * FROM Table WHERE value='$variable' "; $result=mssql_query($sql,$conn); IF (mssql_num_rows($result)==0) { echo"What ever"; } mssql_close($conn);
![]() |
Similar Threads
- Double MySQL Query (PHP)
- MySQL query's (MySQL)
- Change MySQL Query Timeout Period (MySQL)
- pagination of mysql query results (PHP)
- MySQL query to loop through results distinctly (MySQL)
Other Threads in the PHP Forum
- Previous Thread: mktime() issue
- Next Thread: Image Format Detection
| Thread Tools | Search this Thread |
advanced ajax apache api array basics beginner binary broken cakephp check checkbox class cms code combobox cookies cron curl database date datepart display dynamic echo email error file files folder form forms function functions google head href htaccess html image include includingmysecondfileinthechain insert integration ip java javascript job joomla js limit link login loop mail menu mlm multiple mysql oop parse password paypal pdf php problem procedure query radio random recursion regex remote script search server sessions smarty smash sms soap source space sql stored syntax system table traffic tutorial unicode update upload url validator variable video web xml youtube





