MySQL Query --- Warning...

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
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

MySQL Query --- Warning...

Post by tecktalkcm0391 »

How come this code always gives me
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/i4boredo/public_html/uploadimgs.php on line 13

Code: Select all

//starts line 11
$new = mysql_query("INSERT INTO `pictures` (userid) VALUES  (".$userid.")");
$get = mysql_query("SELECT * FROM `pictures` WHERE `userid`=". $userid ." ORDER BY `pictureid` LIMIT 1 DESC");
$nextfile = mysql_fetch_array($get);
$nextfile = $nexfile['pictureid'];
$filename = $nextfile;
$filename_s = $filename.'_s'; 
$filename_m = $filename.'_m';
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

Ok I got it to stop doing that... now using

Code: Select all

$new = mysql_query("INSERT INTO `pictures` (`userid`) VALUES  (".$userid.")");
$get = mysql_query("SELECT `pictureid` FROM `pictures` WHERE `userid` = '". $userid ."' ORDER BY `pictureid` DESC LIMIT 1");
if(!$get){
print("NO");
echo"<br>";
}
$nextfile = mysql_fetch_array($get);
$file = $nextfile['pictureid'];
$filename = $file;
$filename_s = ''.$filename.'_s'; 
$filename_m = ''.$filename.'_m';

// ****
print_r($nextfile);
echo"<br>";
print($file);
echo"<br>";
print($filename);
echo"<br>";
print($filename_s);

die();
And nothing is coming up at all for any of the items that are printed out....only the echos. and "_s" for the $filename_s


Why????
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Code: Select all

$new = mysql_query("INSERT INTO `pictures` (`userid`) VALUES  (".$userid.")");
You never inserted a picture ID, just the user ID
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

thnks i got it now.
Post Reply