Zoofu Posted August 20, 2009 Share Posted August 20, 2009 I've got an image field in my users table, linking to an image. But i want to know how I will show this image? $sql = "SELECT * FROM `users` WHERE `id`='".$uid."'"; ^ | I need the `id`='".$uid."'; part, but I also want to define `image` as a $image var. How? Link to comment https://forums.phpfreaks.com/topic/171106-how-do-i-make-it-so/ Share on other sites More sharing options...
Garethp Posted August 20, 2009 Share Posted August 20, 2009 $sql = "SELECT * FROM `users` WHERE `id`='$uid' AND `image`='$image'"; Link to comment https://forums.phpfreaks.com/topic/171106-how-do-i-make-it-so/#findComment-902332 Share on other sites More sharing options...
Zoofu Posted August 20, 2009 Author Share Posted August 20, 2009 nope, now it's not working. Link to comment https://forums.phpfreaks.com/topic/171106-how-do-i-make-it-so/#findComment-902334 Share on other sites More sharing options...
Garethp Posted August 20, 2009 Share Posted August 20, 2009 Well, echo mysql_query(); What's the error? Link to comment https://forums.phpfreaks.com/topic/171106-how-do-i-make-it-so/#findComment-902336 Share on other sites More sharing options...
trq Posted August 20, 2009 Share Posted August 20, 2009 Define 'not working', your original post is not at all clear. Link to comment https://forums.phpfreaks.com/topic/171106-how-do-i-make-it-so/#findComment-902337 Share on other sites More sharing options...
Zoofu Posted August 20, 2009 Author Share Posted August 20, 2009 Right, since i'm taking everything from it... I tried doing .uid($rowr['image']) but it comes out as a red x. Link to comment https://forums.phpfreaks.com/topic/171106-how-do-i-make-it-so/#findComment-902339 Share on other sites More sharing options...
Zoofu Posted August 20, 2009 Author Share Posted August 20, 2009 For anyone who wants to know... this is the function function uid($uid, $link = FALSE){ $sql = "SELECT * FROM `users` WHERE `id`='".$uid."' AND `image`='".$image."'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0){ return "Invalid User"; }else { $row = mysql_fetch_assoc($res); if(!$link){ return $row['username']; }else { return "<a href=\"/index.php?act=profile&id=".$uid."\">".$row['username']."</a>"; } } } Link to comment https://forums.phpfreaks.com/topic/171106-how-do-i-make-it-so/#findComment-902340 Share on other sites More sharing options...
TeNDoLLA Posted August 20, 2009 Share Posted August 20, 2009 Your image data will be in $row['image'] variable if the field name is image in database. Then just assign $imageVar = $row['image']; Link to comment https://forums.phpfreaks.com/topic/171106-how-do-i-make-it-so/#findComment-902342 Share on other sites More sharing options...
trq Posted August 20, 2009 Share Posted August 20, 2009 The variable $image is not defined anywhere within your function. Assuming it exists outside of the function it will need to be passed in as an argument. Link to comment https://forums.phpfreaks.com/topic/171106-how-do-i-make-it-so/#findComment-902347 Share on other sites More sharing options...
Zoofu Posted August 20, 2009 Author Share Posted August 20, 2009 it's in the users table, so i'm trying to do it as $row['image'] Link to comment https://forums.phpfreaks.com/topic/171106-how-do-i-make-it-so/#findComment-902349 Share on other sites More sharing options...
Zoofu Posted August 20, 2009 Author Share Posted August 20, 2009 Well I can't test any of the suggestions, since Hostzi's FTP is being really irritating, can't wait till I get my proper server back. x.x Filezilla keeps saying there's 2 or more connected with the same user. Link to comment https://forums.phpfreaks.com/topic/171106-how-do-i-make-it-so/#findComment-902351 Share on other sites More sharing options...
Zoofu Posted August 20, 2009 Author Share Posted August 20, 2009 Still getting errors, tell me what I should do with these codes: function uid($uid, $link = FALSE){ $sql = "SELECT * FROM `users` WHERE `id`='".$uid."'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0){ return "Invalid User"; }else { $row = mysql_fetch_assoc($res); if(!$link){ return $row['username']; }else { return "<a href=\"/index.php?act=profile&id=".$uid."\">".$row['username']."</a>"; } } } and the part that matters: $select_sql = "SELECT * FROM `forum_replies` WHERE `tid`='".$id."' ORDER BY id ASC LIMIT ".$end.",".$start.""; $select_res = mysql_query($select_sql) or die(mysql_error()); while($rowr = mysql_fetch_assoc($select_res)){ echo "<tr><td colspan=\"2\" align=\"left\" class=\"forum_header\">Posted On: <em>".$rowr['date']."</em></td></tr>\n"; echo "<tr><td align=\"left\" width=\"15%\" valign=\"top\" class=\"forum_header\">".uid($rowr['uid'], true)."<br><img src=".uid($image)."></td>\n"; //< --- There is where the image will go. echo "<td align=\"left\" valign=\"top\" class=\"forum_header\">\n"; echo nl2br(topic($rowr['message'])); echo "</td>\n"; echo "</tr>\n"; } echo "<form method=\"post\" action=\"./index.php?act=reply&id=".$row['id']."\">\n"; echo "<tr><td colspan=\"2\" align=\"center\"><textarea style=\"width:300px; height:100px\" name=\"reply\"></textarea><br><input type=\"submit\" name=\"submit\" value=\"Add Reply\" style=\"width:100px\"></td></tr>\n"; echo "</table>\n"; Link to comment https://forums.phpfreaks.com/topic/171106-how-do-i-make-it-so/#findComment-902355 Share on other sites More sharing options...
Zoofu Posted August 20, 2009 Author Share Posted August 20, 2009 I really must fix this before I get back to making my anime, I've only got 2 weeks to finish a 30 minute animation. Well, it's only supposed to be 30 seconds but who cares? Lmao. Back on topic: So yeah, I need this pretty fast if anyone could? Link to comment https://forums.phpfreaks.com/topic/171106-how-do-i-make-it-so/#findComment-902359 Share on other sites More sharing options...
trq Posted August 20, 2009 Share Posted August 20, 2009 Your code makes little sense. Firstly you call the function passing at what we assume is a users id. uid($rowr['uid'], true) The next time you call it you seem to pass it an undefined (at least not anywhere in your post) $image variable. uid($image) How exactly do you expect your function to lookup a user based on an image? There is your problem. Now, for homework, fix it. Link to comment https://forums.phpfreaks.com/topic/171106-how-do-i-make-it-so/#findComment-902376 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.