|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
$sqltext= "select userno from qquote where quoteno=$quoteno ";
$result = mysql_query($sqltext); $a = mysql_fetch_row($result); echo "a : " . $a . "<br>"; if $result is blank, the following appeared :- Warning: 0 is not a MySQL result index in ./common.inc on line 246 a : how do i check that $result is empty and then return a value ? thanks |
|
#2
|
|||
|
|||
|
No, if $result==0 you get the warning.
a result of 0 on a mysql query means that the mysql server returned an error. It does not mean an empty set. |
|
#3
|
|||
|
|||
|
However if you wanted to check to see if it result was empty anyways, you can do this:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre> <? $sqltext= "select userno from qquote where quoteno=$quoteno "; $result = mysql_query($sqltext); if(mysql_num_rows($result)>0){ $a = mysql_fetch_row($result); echo "a : " . $a . "<br>"; }else{ echo "empty query"; } ?> [/quote] |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > PHP Development > if $result is empty rror appeared ? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|