fallenangel1983 Posted March 20, 2008 Share Posted March 20, 2008 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 Link to comment https://forums.phpfreaks.com/topic/97147-warning-mysql_numrows-supplied-argument-is-not-a-valid-mysql-result-resource/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 20, 2008 Share Posted March 20, 2008 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. Link to comment https://forums.phpfreaks.com/topic/97147-warning-mysql_numrows-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-497108 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.