Jump to content

[SOLVED] Help With Warning


herghost

Recommended Posts

Anyone solve this for me?

 

Warning: mysql_fetch_array(): 11 is not a valid MySQL result resource in C:\wamp\www\project\view_topic.php on line 92

<?php
session_start()
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="Description" content="" />
<meta name="Keywords" content="" />
<meta name="Robots" content="index,follow" />
<link rel="stylesheet" href="images/CoolWater.css" type="text/css" />
<title>Project</title>
</head>

<body>
<div id="wrap">
<?php include('include/header.php'); ?>

<!-- content-wrap starts here -->
    
<div id="content-wrap">

	<div id="main">
<?php

include('include/dbconnect.php');

$query="SELECT user_id FROM forum_question WHERE username = '" . $_SESSION['username'] ."'";
$result=mysql_query($query) or die ("oh dear   " .mysql_error()) ;
while($rows=mysql_fetch_array($result))
															{
																$_SESSION['user_id'] = $rows['user_id'];
															}


$id=$_GET['id'];
$sql="SELECT * FROM forum_question WHERE id='$id'";
$result=mysql_query($sql) or die ("oh dear   " .mysql_error()) ;
while($rows=mysql_fetch_array($result))
															{?>

<h1> 		<?php echo $rows['title'];?>   </h1>

		<table>
		<tr>
		<th>System Info: </th><td>Operating System: <?php echo $rows['os'] ;?>,<br />
			Amount of Ram: <?php echo $rows['ram'] ;?>,<br />
			Harddrive Type &amp Size: <?php echo $rows['harddrive'] ;?>, <br />
		Graphics Card: <?php echo $rows['graphics'] ;?></td>
		</tr>

            <tr>
		<th>Topic: </th><td> <?php echo $rows['title'] ;?> </td>
		</tr>

            <tr>
		<th>Posted By: </th><td> <?php echo $rows['username'] ;?> </td>
		</tr>
            
		<tr>
		<th>Posted On: </th><td> <?php echo $rows['datetime'] ;?> </td>
		</tr>

		<tr>
		<th>Description: </th><td> <?php echo $rows['detail'];?> </td>
		</tr>

															<?php }?>
		<tr>
		<th>Download DxDIAG:</th>

			<?php $query = "SELECT u_id, name FROM upload WHERE post_no = '$id'";
			$result = mysql_query($query) or die('Error, query failed');
			if(mysql_num_rows($result) == 0)
				{
				echo "No DxDIAG Exists <br>";
				}
			else
				{
				while(list($u_id, $name) = mysql_fetch_array($result))

				?>
			<td><a href="forum/download.php?id=<?php echo $id;?>">Download</a></td><br>
			</table>



                        
                        <?php

					$sql99="SELECT userlevel FROM users_info WHERE user_id = '" . $_SESSION['user_id'] ."'";
					$result=mysql_query($sql99) or die ("oh dear   " .mysql_error()) ;
					while($rows=mysql_fetch_array($result))
						{

					if  ($rows['userlevel'] > 3 || $rows['user_id'] == $_SESSION['user_id']) 
					{

						$sql2="SELECT * 
						FROM forum_answer 
						WHERE question_id='$id'";
						$result2=mysql_query($sql2) or die ("oh dear   " .mysql_error()) ;
						while($rows=mysql_fetch_array($result2))
							{
					?>
                        <table width="95%" border="0">
                        <hr> <h3>Reply Number<?php echo $rows['a_id'] ;?></h3>
  <tr>
    <th width="20%">Posted On: </th>
    <td><span style="color:#0F7"><?php echo $rows['a_datetime'] ;?></span></td>
    </tr>
  <tr>
    <th width="20%"><?php echo $rows['a_username'];?>'s Reply:</th>
    <td><span style="color:#00F"> <?php echo $rows['a_answer']; ?></span></td>
  </tr>
</table>
<?php } }?>

                                     			<?php
											$query = "SELECT username
											FROM forum_question";
											$result = mysql_query($query, $conn) or die(mysql_error($conn));
											$row = mysql_fetch_array($result);
											extract($row);
											mysql_free_result($result);

											if ($username == $_SESSION['username'])
											{
												?>
                                                   <form method="post" action="forum/forums/is_solved.php">
                                                    <input type="submit" class="button" value="This Fixed It" />
                                                    </form>
                                                    <?php 
											}
												?>

						<?php
							}
								}

							$sql3="SELECT view 
							FROM forum_question 
							WHERE id='$id'";
							$result3=mysql_query($sql3) or die ("oh dear   " .mysql_error()) ;
							$rows=mysql_fetch_array($result3);
							$view=$rows['view'];

							// if have no counter value set counter = 1
							if(empty($view))
								{
							$view=1;
							$sql4="INSERT INTO forum_question(view)
							VALUES('$view') 
							WHERE id='$id'";
							$result4=mysql_query($sql4)or die ("oh dear   " .mysql_error()) ;
								}

								// count more value
								$addview=$view+1;
								$sql5="UPDATE forum_question
								SET view='$addview' 
								WHERE id='$id'";
								$result5=mysql_query($sql5)or die ("oh dear   " .mysql_error()) ;



?> 
  



					<form method="post" action="forum/forum/add_answer.php?id=<?php echo $id ; ?>">			
                        <label><?php echo $_SESSION['username']; ?>'s Reply</label>
					<textarea rows="5" cols="5" name="answer" id="answer"></textarea>
					<input name="id" type="hidden" value="<?php echo $id ;?>" />
					<input class="button" type="submit" />		
					</form>	
                        
                        <table>
                <tr>
			<th><a href="solutions.php">Back</a></th>
               
			</tr>
                </table>
</div>		
<?php
if (isset($_SESSION['logged']) && $_SESSION['logged'] == 1) 

{ include('include/sidebar_1.php'); }


                                     
else

{ include('include/sidebar_0.php'); }			
?>
    <!-- content-wrap ends here -->	
    </div>				
<?php include('include/footer.php');?>
<!-- wrap ends here -->
</div>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/175587-solved-help-with-warning/
Share on other sites

$userID = $_SESSION['user_id'];

$result = mysql_query("SELECT * FROM users_info WHERE user_id='$userID' LIMIT 1") or die(mysql_error());  
$row = mysql_fetch_array($result);

echo $row['userlevel'];

 

 

I add LIMIT 1 as I am assuming your are only seeking a single users level. Also because its good practice to limit your querys for optimization, for security, and all else.

 

Also I made a var based off the session you were using for your search query.

Adding it to the SQL query like this it wasnt reading the query correctly.

 

" . $_SESSION['user_id'] ."

 

Aside from the manuals online I would suggest taking a skim through tizag.com which offers great tutorials for people just starting out.. or needing the occasional reminder on stuff..

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.