| | |
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 |
apache api array auto beginner binary broken cache cakephp checkbox class cms code codingproblem cron curl customizableitems database date display dynamic echo email error errorlog file files filter folder form format forms forum function functions gc_maxlifetime global google headmethod href htaccess html image include insert ip javascript joomla limit link login mail malfunctioning memmory memory menu method mlm multiple mysql nodes oop parameter parsing paypal pdf php phpmysql popup query radio random recursion recursiveloop remote script search select server sessions snippet source space sql static survey syntax system table trouble tutorial up-to-date update upload url validator variable video web youtube





