[SOLVED] query error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
C_Calav
Forum Contributor
Posts: 395
Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand

[SOLVED] query error

Post by C_Calav »

hi guys,

got this query thats not working out and dont know why can anyone see anything wrong?

thanx guys

EDIT. this error is comming up becuase the first time i go to the page nothing is selected. once i select something i get this error now
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Apache2\htdocs\survey\users.php on line 78
Unknown column 'IT' in 'where clause'

Code: Select all

<?php 
   include("conection.php");    

     $e_dept = $_POST&#1111;"select_dept"];

     $query = "select * from tbl_emp WHERE e_dept=$e_dept"; 
     $result = mysql_query($query); 
     $num_results = mysql_num_rows($result) or die (mysql_error()); 
    
     for ($i=0; $i <$num_results; $i++) 
     &#123; 
     $row = mysql_fetch_array($result); 
      
     $e_first = $row&#1111;'e_first']; 
?>
Last edited by C_Calav on Mon Jan 31, 2005 7:26 pm, edited 1 time in total.
User avatar
C_Calav
Forum Contributor
Posts: 395
Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand

Post by C_Calav »

fixed.. needed single quotes

Code: Select all

WHERE e_dept='$e_dept'";
solved my own thread ... hmmmm :roll:
Wldrumstcs
Forum Commoner
Posts: 98
Joined: Wed Nov 26, 2003 8:41 pm

Post by Wldrumstcs »

change the line with the query to

Code: Select all

WHERE e_dept='$e_dept'";
You need the single quotes in there.

EDIT: Whoops, you found it too.
Post Reply