hi
i have problem , rhe code is working properly on local machine but when i upload it on net then it give the warning
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home7/wyzerpmc/public_html/wyzer/survey/survey.php on line 22

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<center>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
  <table width="800" border="0" cellspacing="0" cellpadding="0">
    <tr> 
      <td height="50" colspan="3" bgcolor="#99CCFF">&nbsp;</td>
    </tr>
    <tr> 
      <td width="300" bgcolor="#99CCFF">&nbsp;</td>
      <td width="500"> 
        <?php 

ob_start();
include_once("connection.php");
	$sql="SELECT *
	FROM `question`";
	$quer=mysql_query($sql);
		while($row=mysql_fetch_array($quer))		{
		echo $row[uniqueid].") ".$row[stem]."<br>";
		$qid= $row[uniqueid];
				$sql1="select * from scale where uniqueid=$qid ;";
				$quer1=mysql_query($sql1);
				while($row1=mysql_fetch_array($quer1))
				{
				
				?>
        <input type="<?php echo $row[type];  ?>" name="<?php echo $row[questionID];  ?>" value="<?php echo $row1[label];  ?>"> 
        <?php echo $row1[label]; ?> <br> 
        <?php
				
				}
			echo "<hr>";		
		}


ob_end_flush();
?>
      </td>
      <td width="200" bgcolor="#99CCFF">&nbsp;</td>
    </tr>
    <tr> 
      <td colspan="3" bgcolor="#99CCFF">&nbsp;</td>
    </tr>
  </table>
</body>
</center>
</html>

seems to be bit all over the place try this

$sql="SELECT * FROM `question`";
$quer=mysql_query($sql);
while($row=mysql_fetch_array($quer)) {

echo ".$row[uniqueid]." ".$row[stem]."<br>";
$qid= $row[uniqueid];
}
while($row=mysql_fetch_array($quer)) {
echo $row[uniqueid].") ".$row[stem]."<br>";
$qid= $row[uniqueid];
$sql1="select * from scale where uniqueid=$qid ;";
$quer1=mysql_query($sql1);
while($row1=mysql_fetch_array($quer1))
{

?>
<input type="<?php echo $row[type]; ?>" name="<?php echo $row[questionID]; ?>" value="<?php echo $row1[label]; ?>"> 
<?php echo $row1[label]; ?> <br> 
<?php

}
echo "<hr>"; 
}

I am unsure if this is solved but to add to the info, if no rows are found the same error will be reported. To solve this, replace the code in the quote with the following:

if (mysql_num_rows($quer)>0) {
while($row=mysql_fetch_array($quer)) {
echo $row[uniqueid].") ".$row[stem]."<br>";
$qid= $row[uniqueid];
$sql1="select * from scale where uniqueid=$qid ;";
$quer1=mysql_query($sql1);
while($row1=mysql_fetch_array($quer1))
{

?>
<input type="<?php echo $row[type]; ?>" name="<?php echo $row[questionID]; ?>" value="<?php echo $row1[label]; ?>"> 
<?php echo $row1[label]; ?> <br> 
<?php

}
echo "<hr>"; 
}
}
Comments
Absolutely..

yes not sure if it was solved but he said that's good so i guess it solved the problem?? if this is solved pleae mark as solved thanks

hi
i have problem , rhe code is working properly on local machine but when i upload it on net then it give the warning
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home7/wyzerpmc/public_html/wyzer/survey/survey.php on line 22

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<center>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
  <table width="800" border="0" cellspacing="0" cellpadding="0">
    <tr> 
      <td height="50" colspan="3" bgcolor="#99CCFF">&nbsp;</td>
    </tr>
    <tr> 
      <td width="300" bgcolor="#99CCFF">&nbsp;</td>
      <td width="500"> 
        <?php 

ob_start();
include_once("connection.php");
	$sql="SELECT *
	FROM `question`";
	$quer=mysql_query($sql);
		while($row=mysql_fetch_array($quer))		{
		echo $row[uniqueid].") ".$row[stem]."<br>";
		$qid= $row[uniqueid];
				$sql1="select * from scale where uniqueid=$qid ;";
				$quer1=mysql_query($sql1);
				while($row1=mysql_fetch_array($quer1))
				{
				
				?>
        <input type="<?php echo $row[type];  ?>" name="<?php echo $row[questionID];  ?>" value="<?php echo $row1[label];  ?>"> 
        <?php echo $row1[label]; ?> <br> 
        <?php
				
				}
			echo "<hr>";		
		}


ob_end_flush();
?>
      </td>
      <td width="200" bgcolor="#99CCFF">&nbsp;</td>
    </tr>
    <tr> 
      <td colspan="3" bgcolor="#99CCFF">&nbsp;</td>
    </tr>
  </table>
</body>
</center>
</html>

use
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))

second arg as MYSQL_ASSOC always ..........

This article has been dead for over six months. Start a new discussion instead.