simcoweb Posted September 14, 2006 Author Share Posted September 14, 2006 Ok, makes sense. Then how would I call the image? Seems everything I try turns to mush. Example, please? Quote Link to comment Share on other sites More sharing options...
Barand Posted September 14, 2006 Share Posted September 14, 2006 see reply #22 by mainewoodsAnd in your query, are you sure it's imageName = 'memberid' or do you have a member id column?(Also memberid should be $memberid if you are storing it in a variable) Quote Link to comment Share on other sites More sharing options...
simcoweb Posted September 14, 2006 Author Share Posted September 14, 2006 Yes, there is a 'memberid' column/field in the database.Also, I may be wrong with the 'imagename' field. That may be an actual name like 'My Dog Charlie' instead of the actual filename. There's another field called 'fileName' that contains the image name so that needs to be switched. Just a note, though, the same data is in both fields presently so it would call the image in either case.Now, i'm not 100% sure if i'm understnading the 'WHERE' part. My understanding is that i'm 'connecting' or 'referring' the [b]imageName[/b] to the member's ID ( 'memberid' ) so that it knows which one to display for which member. I'll admit i've been wrong on 99.9999% of my assumptions so that's probably another one. So, bottom line is i'm not 100% sure how i'd write that part of the query. Quote Link to comment Share on other sites More sharing options...
simcoweb Posted September 14, 2006 Author Share Posted September 14, 2006 Barand, after inserting that line I get this error message:[quote]Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 46 in /home2/wwwplat/public_html/display.php on line 16[/quote]You can view the page here: [url=http://www.plateauprofessionals.com/display.php]http://www.plateauprofessionals.com/display.php[/url]Also note that the characters '; show up to the right of where the image should be displayed. This should be the closing of the echo statement but for some reason it's displaying it as text. Quote Link to comment Share on other sites More sharing options...
simcoweb Posted September 14, 2006 Author Share Posted September 14, 2006 UPDATE: The images now are viewable and are coordinated with the proper profile! However, that error code is still present. So, I can either edit that line or if you have another suggestion... Quote Link to comment Share on other sites More sharing options...
simcoweb Posted September 14, 2006 Author Share Posted September 14, 2006 Still getting this error message:[quote]Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 46 in /home2/wwwplat/public_html/display4.php on line 16[/quote]From this line:[code]$image = mysql_result($result2, 0, 'photo');[/code]Please advise. Thanks! Quote Link to comment Share on other sites More sharing options...
Barand Posted September 14, 2006 Share Posted September 14, 2006 So if your table has these columns[pre]member_id | imageName | fileName-----------|-----------------|----------------- 1 | My dog Charlie | charlie.jpg 2 | My cat Felix | felix.jpg[/pre] and you want to display the image of the cat, you need to[code]<?php$memberid = 2;$sql = "SELECT fileName FROM members WHERE member_id = '$memberid'";$result = mysql_query($sql);$image = mysql_result($result,0,'fileName');echo "<img src='$image'>";?>[/code]If you are getting that error message its because it couldn;t find a record with id you specified.To check for that event,[code]<?php$memberid = 2;$sql = "SELECT fileName FROM members WHERE member_id = '$memberid'";$result = mysql_query($sql);if (mysql_num_rows($result) > 0) { $image = mysql_result($result,0,'fileName'); echo "<img src='$image'>";}?>[/code] Quote Link to comment Share on other sites More sharing options...
simcoweb Posted September 14, 2006 Author Share Posted September 14, 2006 Hi Barand:In your first example that pertains to calling a single row. I'm actually calling all the rows in that table as an array and displaying them in a 'while' loop. The images show up fine. But that error shows at the top of the page. Take a peek:[url=http://www.plateauprofessionals.com/display.php]http://www.plateauprofessionals.com/display.php[/url]This:[code]$sql2=("SELECT photo FROM plateau_pros WHERE photo='photo'");$result2 = mysql_query($sql2) or die(mysql_error());$image = mysql_result($result2, 0, 'photo');[/code]is leading to this:[code]while ($row = mysql_fetch_assoc($result)) { extract($row); echo <<<HTML blah blah blah[/code]and in the HTML is the image code:[code]<td style='padding-left: 10px; padding-right: 10px; padding-top:5px; padding-bottom:5px' width='229' valign='top'><img src='images/photo/$photo' width='175' height='225'></td>[/code]In the mysql database there's no more 'imageName' field. Didn't need it so I deleted it. Also, the 'fileName' field I changed the title to 'photo'. Plus, edited all code to use that field name. Seems to work fine except for that error. Quote Link to comment Share on other sites More sharing options...
Barand Posted September 14, 2006 Share Posted September 14, 2006 I did it with a single row because you said [quote]I've even created a second sql query just for the images:Code:$sql2=("SELECT imageName FROM members WHERE imageName='memberid'");$result2 = mysql_query($sql2) or die(mysql_error());And set a variable as: $image = $sql['imageName'];No matter what i've done/do I can't get this simple friggin image to show up. Help?[/quote]If images now working ok in loop, do you now need that call that's producing the single row? Quote Link to comment Share on other sites More sharing options...
simcoweb Posted September 14, 2006 Author Share Posted September 14, 2006 Apparently not ;D I commented them out. Error go bye bye and images still show up. I guess I wasn't sure if the images were showing up because of that line since they started showing up at the same time I inserted it. However, I made about 4,000,324,234,212 changes to that page so keeping up with what worked got a little screwy about 2am. Thanks again for the help, Barand! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.