Jump to content

Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource


fallenangel1983

Recommended Posts

Hey all,

 

I know this problem has been solved on this problem before but i have been trauling the forums for ages and cant seem to get a result could someone help? heres my code:

 

 

 

<?php #viewEvent.php

 

session_start();

 

?>

 

<html>

<head></head>

<title>View Events</title>

 

<body bgcolor="lightyellow">

<center>

 

<?

 

$pass = $_SESSION['password'];

$user = $_SESSION['username'];

 

$db_name="project";

 

mysql_connect("localhost","root","") or die("cannot connect");

mysql_select_db("$db_name")or die("cannot select DB");

 

$viewevent="SELECT * FROM events WHERE username LIKE '$user'";

$result=mysql_query($viewEvent);

$num=mysql_numrows($result);

 

echo "<b><center>Your Events</center></b><br><br>";

 

$i=0;

while ($i < $num)

{

  $eventID=mysql_result($result,$i,"eventID");

  $usernamemy=sql_result($result,$i,"username");

  $department=mysql_result($result,$i,"department");

  $softHard=mysql_result($result,$i,"softHard");

  $eventDesc=mysql_result($result,$i,"eventDesc");

  $solved=mysql_result($result,$i,"solved");

  $solID=mysql_result($result,$i,"solID");

 

  echo "<b>$eventID</b><br>$username</b><br>$department</br><br>$eventDesc</br><br>$solved</br><br>$solID<hr><br></br>";

 

$i++;

}

 

?>

 

 

the error i get:

 

Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource

 

 

any help would be appreciated. cheers

 

 

If you bother to search for that error message you find discover that you query is failing but your code has no error checking, error reporting, and error recovery logic to get it to tell you why the query failed.

 

Search and you will find what to change in your code to get php/mysql to tell you what the problem is.

 

We cannot actually tell because that would require us to know enough information about your table to know if your query matches what your table is.

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.