monika Posted August 12, 2007 Share Posted August 12, 2007 <?php $Array["regno"] =trim ($Array["regno"]); include("configresult.php"); $Link = mysql_connect($Host, $User, $Password); $Query="SELECT * from $TableName Where regno= $Array[regno]"; $Result= mysql_db_query ($DBName, $Query, $Link); if ($Row = mysql_fetch_array ($Result)){ print (" REG.No: $Row[regno] Class: $Row[class] <br />NAME: $Row[firstname] <br /> Status: $Row[divs] <BR> "); } else { echo '<font size="2" face="Tahoma" font color="#FF0000" font-weight:"Normal"> Sorry, Invalid Registration No! </font>'; } mysql_close ($Link); ?> ------ Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource .....on line 25 What's wrong with this code.. i'm unable to figure out... day ago it was working fine. Quote Link to comment https://forums.phpfreaks.com/topic/64469-mysql_fetch_array/ Share on other sites More sharing options...
lightningstrike Posted August 12, 2007 Share Posted August 12, 2007 Use print $Query; to see what your code is actually outputting. I have a feeling the array key may have invalid data. Quote Link to comment https://forums.phpfreaks.com/topic/64469-mysql_fetch_array/#findComment-321390 Share on other sites More sharing options...
monika Posted August 12, 2007 Author Share Posted August 12, 2007 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in searchresults.php on line 25 Sorry, Invalid Registration No! SELECT * from results Where regno= Quote Link to comment https://forums.phpfreaks.com/topic/64469-mysql_fetch_array/#findComment-321391 Share on other sites More sharing options...
lightningstrike Posted August 12, 2007 Share Posted August 12, 2007 Exactly. It's invalid because $Array["regno"] has no value. Double check where the data is coming from. Quote Link to comment https://forums.phpfreaks.com/topic/64469-mysql_fetch_array/#findComment-321393 Share on other sites More sharing options...
monika Posted August 12, 2007 Author Share Posted August 12, 2007 <FORM NAME="searchresults" METHOD="POST" ACTION="searchresults.php"> <table cellpadding="0" cellspacing="0" style="width: 396px; height: 1px"> <!-- MSTableType="layout" --> <tr> <td style="height: 16px"> <div class="colum_right_border_bottom" style="width: 535px; height: 6px"> </div> </td> </tr> </table> <p align="center"><font face="Arial" style="font-size: 8pt"><strong>Search your Examination Result</strong></font></p> <p style="height: 98px"><font face="Verdana" style="font-size: 8pt">Enter your Reg. No</font><font style="font-size: 8pt">.</font> <input name="Array[regno]" type="text" id="Array[regno]" class="formbox" size="16"><BR> <input type="submit" name="Submit" value="Submit" class="formbox"><br> <font face="Arial" style="font-size: 8pt" color="#8A8A8A"><br> Enter your Registration Number and press the Submit button.</font></p> </FORM> Quote Link to comment https://forums.phpfreaks.com/topic/64469-mysql_fetch_array/#findComment-321396 Share on other sites More sharing options...
lightningstrike Posted August 12, 2007 Share Posted August 12, 2007 Ouch NEVER use register_globals. $Array["regno"] = addslashes(trim($_POST["Array[regno]"])); Better yet <input name="regno" type="text" id="regno" class="formbox" size="16"><BR> $Array["regno"] = addslashes(trim($_POST["regno"])); Quote Link to comment https://forums.phpfreaks.com/topic/64469-mysql_fetch_array/#findComment-321402 Share on other sites More sharing options...
monika Posted August 12, 2007 Author Share Posted August 12, 2007 <input name="regno" type="text" id="regno" class="formbox" size="16"><BR> <input type="submit" name="Submit" value="Submit" class="formbox"><br> ------------------ <?php $Array["regno"] =addslashes(trim($_POST["regno"])); include("configresult.php"); $Link = mysql_connect($Host, $User, $Password); $Query="SELECT * from $TableName Where regno= $Array[regno]"; $Result= mysql_db_query ($DBName, $Query, $Link); if ($Row = mysql_fetch_array ($Result)){ print (" REG.No: $Row[regno] Class: $Row[class] <p></P>NAME: $Row[firstname] <p></P> Status: $Row[divs] <BR> "); } else { echo '<font size="2" face="Tahoma" font color="#FF0000" font-weight:"Normal"> Sorry, Invalid Registration No! </font>'; } mysql_close ($Link); ?> ----------- error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /searchresults.php on line 24 Sorry, Invalid Registration No! Quote Link to comment https://forums.phpfreaks.com/topic/64469-mysql_fetch_array/#findComment-321411 Share on other sites More sharing options...
monika Posted August 12, 2007 Author Share Posted August 12, 2007 well the problem was there was no particular data in database so every time i put regno 3030B that error comes.. actualy indatabase there is only3030 Quote Link to comment https://forums.phpfreaks.com/topic/64469-mysql_fetch_array/#findComment-321798 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.