Current location: Hot Scripts Forums » Programming Languages » PHP » mysql fetch error

mysql fetch error

Reply
  #1 (permalink)  
Old 07-03-09, 09:08 AM
xEX3CUT1ONx xEX3CUT1ONx is offline
Newbie Coder
 
Join Date: Jun 2008
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
mysql fetch error

Hello, I'm currently working on an upload area for members of a site, so far I have it so that when a file is uploaded it adds the file name into the database along with the user who submitted it.

Now I am trying to get it so that it will list all of the files that are uploaded by the username that is registered in the current session.

My code for this part is :

PHP Code:
echo"<table id='upload_table' width='500px' id='uploaded_table'><tr>
<th align='left' id='id_upload'>ID</th>
<th align='left' id='file_upload'>File Name</th>
</tr>"
;
    
    
$fetch_files mysql_query("SELECT * FROM 'uploaded' WHERE submit_user = $curr_user ORDER BY ID");
    while(list(
$ID,$filename)=mysql_fetch_row($fetch_files)){
    
    echo
"<tr>
<td width='5%'>$ID</td>
<td><a href='$target_path$filename' target='_blank'>$filename</a></td>
<td width='5%'><form action='delete.php' method='post'><input type='hidden' name='delete' value='$ID'><input type='submit' id='delete_upload' name='submit' value='Delete'></form></td>
</tr>"
;
}
echo
"</table>";
    

I cannot see where the error is, but the error I am getting is:

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\upload_members.php on line 87, Line 87 is

PHP Code:
while(list($ID,$filename)=mysql_fetch_row($fetch_files)){ 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-03-09, 09:28 AM
End User's Avatar
End User End User is online now
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 2,832
Thanks: 13
Thanked 10 Times in 9 Posts
Quote:
Originally Posted by xEX3CUT1ONx View Post
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\upload_members.php on line 87, Line 87 is
This typically indicates that there was no result from your query, but that you're going ahead anyway and trying to use the (non-existent) result. It's possible that this line:

$fetch_files = mysql_query("SELECT * FROM 'uploaded' WHERE submit_user = $curr_user ORDER BY ID");

needs to be changed to this:

$fetch_files = mysql_query("SELECT * FROM uploaded WHERE submit_user = '$curr_user' ORDER BY ID");

(remove quotes around 'uploaded' and place quotes around '$curr_user')
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data (scroll down)

Last edited by End User; 07-03-09 at 09:32 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-03-09, 10:52 AM
xEX3CUT1ONx xEX3CUT1ONx is offline
Newbie Coder
 
Join Date: Jun 2008
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you for the help EndUser, it works perfectly now
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ and MSSQL tutorials? scott2500uk C/C++ 8 05-11-09 03:33 AM
Syntax Error Nikas Database 4 05-15-08 11:48 AM
MySQL Error umarrana PHP 1 10-19-07 07:35 AM
MySQL Syntax error gigafare PHP 4 04-19-06 03:03 AM
mysql fetch array error - what could be wrong? fatphil PHP 2 02-25-06 01:22 PM


All times are GMT -5. The time now is 07:27 PM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.