runnerjp Posted December 5, 2007 Author Share Posted December 5, 2007 function get_id ( $id ) { global $db; $query = "SELECT `ID` FROM `" . DBPREFIX . "users` WHERE `ID` = " . $db->qstr ( $id ); if ( $db->RecordCount ( $query ) == 1 ) { $row = $db->getRow ( $query ); return $row->ID; } else { return FALSE; } } Quote Link to comment Share on other sites More sharing options...
runnerjp Posted December 5, 2007 Author Share Posted December 5, 2007 ok can any 1 help me with this lil bit  $sql = 'SELECT `ext` FROM `user_image` WHERE `user_id`= $pID' ; $q = mysql_query($sql); if($q){  $row = mysql_fetch_array($q);  if(!empty($row)){   echo '<img src="http://www.runningprofiles.com/members/images/'     $pID. $row['ext']. '" />';  } }else{  echo 'Error: Image not found.'; }  how can i right this properly $pID. $row['ext']. '" />'; Quote Link to comment Share on other sites More sharing options...
trq Posted December 5, 2007 Share Posted December 5, 2007 Once again, why are you querying the database for the extension? There are only a limited number of possible extensions and really, there is no need wasting resources querying for it.  As for how to write your line properly....  echo '<img src="http://www.runningprofiles.com/members/images/' . $pID. $row['ext'] . '" />'; Quote Link to comment Share on other sites More sharing options...
runnerjp Posted December 5, 2007 Author Share Posted December 5, 2007 its still not outputting an image... any idea why.. i thought i had it by gtting user id and then looking up extension file to the id so i.jpg and then echo '<img src="http://www.runningprofiles.com/members/images/' . $pID. $row['ext'] . '" />'; should show it Quote Link to comment Share on other sites More sharing options...
runnerjp Posted December 5, 2007 Author Share Posted December 5, 2007 i dont get why its not working surly it should get . $pID. $row['ext']  or 1.jpeg Quote Link to comment Share on other sites More sharing options...
runnerjp Posted December 5, 2007 Author Share Posted December 5, 2007 ok $sql = 'SELECT `ext` FROM `user_image` WHERE `user_id`='$pid; $q = mysql_query($sql); if($q){  $row = mysql_fetch_array($q);  if(!empty($row)){   echo '<img src="http://www.runningprofiles.com/members/images/' . $pID. "." $row['ext'] . '" />';  } }else{  echo 'Error: Image not found.'; }*/ should do it if 2 things  1.`user_id`='$pid; how would i display this correctly?  2. echo '<img src="http://www.runningprofiles.com/members/images/' . $pID. "." $row['ext'] . '" />'; is this correct way of showin id.ext?? or 1.jpg Quote Link to comment Share on other sites More sharing options...
helraizer Posted December 6, 2007 Share Posted December 6, 2007 ok $sql = 'SELECT `ext` FROM `user_image` WHERE `user_id`='$pid; $q = mysql_query($sql); if($q){  $row = mysql_fetch_array($q);  if(!empty($row)){   echo '<img src="http://www.runningprofiles.com/members/images/' . $pID. "." $row['ext'] . '" />';  } }else{  echo 'Error: Image not found.'; }*/ should do it if 2 things  1.`user_id`='$pid; how would i display this correctly?  2. echo '<img src="http://www.runningprofiles.com/members/images/' . $pID. "." $row['ext'] . '" />'; is this correct way of showin id.ext?? or 1.jpg  If I am correct in thinking, the URL you should use single quotes for the "." as '.' because at the moment you've broken the URL up. echo '<img src="http://www.runningprofiles.com/members/images/' . $pID . '.' .$row['ext'] . '" />'  Sam Quote Link to comment Share on other sites More sharing options...
SirChick Posted December 6, 2007 Share Posted December 6, 2007 What i would of done is if the picture is always in the same place on the screen.... just echo the username ontop of the image using absolute position in div tags... so it looks like its part of the picture when infact its actually "above the image" Â Plus if its using a $Username.. when ever the name is changd it will change according.. how ever this won't work if the picture is not always in the same place. Quote Link to comment Share on other sites More sharing options...
trq Posted December 6, 2007 Share Posted December 6, 2007 is this correct way of showin id.ext?? or 1.jpg  Where in your code do you toell it to display 1.jpg if no record is found? You don't! This thread is getting out of hand. You seriously need to learn the basics and come back to this idea in a few months when you get it. Quote Link to comment Share on other sites More sharing options...
runnerjp Posted December 6, 2007 Author Share Posted December 6, 2007 <?$sql = 'SELECT `ext` FROM `user_image` WHERE `user_id`=$pid; $q = mysql_query($sql); if($q){  $row = mysql_fetch_array($q);  if(!empty($row)){  echo '<img src="http://www.runningprofiles.com/members/images/' . $pID . '.' .$row['ext'] . '" />'  } }else{  echo 'Error: Image not found.'; } ?>  but thorpe i know how to display 1.jpg if the image insnt found i will add that later.. my point is that i cant get the users image first!!  echo '<img src="http://www.runningprofiles.com/members/images/' . $pID . '.' .$row['ext'] . '" />'... has a nexpected T_STRING Quote Link to comment Share on other sites More sharing options...
runnerjp Posted December 6, 2007 Author Share Posted December 6, 2007 $sql = 'SELECT `ext` FROM `user_image` WHERE `user_id`=' . $_GET['id']; $q = mysql_query($sql); if($q){ Â $row = mysql_fetch_array($q); Â echo 'emma'; Â if(!empty($row)){ Â echo '<img src="http://www.runningprofiles.com/members/images/' . $pID. $row['ext'] . '" />'; Â } }else{ Â echo 'Error: Image not found.'; } Â fixed the error on my own lol showing i can fix some errors lol but not one not displaying the image :S Quote Link to comment Share on other sites More sharing options...
runnerjp Posted December 6, 2007 Author Share Posted December 6, 2007 *bump* Quote Link to comment Share on other sites More sharing options...
trq Posted December 6, 2007 Share Posted December 6, 2007 Seriously, I think this thread has gone on long enough. If you can't fix your problems with 100+ replies to your thread, there are bigger issues. Â Firstly, try some debugging. Where the hell does $pID come from? What does it contain (echo it to find out)? Does what it contains relate to an actual image name? Â I'll say it again, I see no reason for you to be using a database in this situation at all. However, you seam to have completely ignored this (and I would assume alot of other) good advice. Â Seams to me you don't have a good grasp of the basics yet. Maybe a read of the free book in my signiture could get you heading down the right path? Quote Link to comment Share on other sites More sharing options...
runnerjp Posted December 7, 2007 Author Share Posted December 7, 2007 im doing this with tinkering ect.. i do have a problem  $query = "SELECT ext FROM user_image WHERE user_id='$user_id' LIMIT 1";  it give me #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$query = "SELECT ext FROM user_image WHERE user_id='$user_id' LIMIT 1"' at line 1   can any 1 enlighten me on this please?  oh and thrope... if there are 2 images by the user in the folder e.g 1.jpg 1.gif then the script will show more then 1 ? Quote Link to comment Share on other sites More sharing options...
runnerjp Posted December 7, 2007 Author Share Posted December 7, 2007 ok took every ones advise and i suppose i shudda sat down and pulled it apart myself but i got it working thanks guys   at last i can close this thread lol Quote Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted December 7, 2007 Share Posted December 7, 2007 NO WAY!!! heheheh  grats everyone!! beers all around! = ^D  PhREEEk Quote Link to comment Share on other sites More sharing options...
runnerjp Posted December 7, 2007 Author Share Posted December 7, 2007 i do have anouther weeee problem  the code always trys to find the users id with the ext....  if(isset($q)){ while ($row = mysql_fetch_array($q)) {   echo "<img src='http://www.runningprofiles.com/members/images/".     $pid . "." . $row['ext']. "' />";  } }else{  echo "<img src='http://www.runningprofiles.com/members/images/pic.jpg />";  }   it wont echo the pic.jpg if there are no files...how comes?  Quote Link to comment Share on other sites More sharing options...
adam291086 Posted December 7, 2007 Share Posted December 7, 2007 because there is no information in the array left to echo. Therefore it goes to your else statement. Quote Link to comment Share on other sites More sharing options...
runnerjp Posted December 7, 2007 Author Share Posted December 7, 2007 humm so how would i go about showing the image if no image iss found ?? Quote Link to comment Share on other sites More sharing options...
runnerjp Posted December 7, 2007 Author Share Posted December 7, 2007 need a default image to be shown Quote Link to comment Share on other sites More sharing options...
adam291086 Posted December 7, 2007 Share Posted December 7, 2007 what you have already should do what you want.  While there is information from the database echo there picture  else  echo "<img src='http://www.runningprofiles.com/members/images/pic.jpg />";  That should work. Do you have a picture called pic.jpg? Quote Link to comment Share on other sites More sharing options...
runnerjp Posted December 7, 2007 Author Share Posted December 7, 2007 i do but every time it just adds eg 4.jpg if users name is 4Â even if there is no file :S Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted December 7, 2007 Share Posted December 7, 2007 I suspect that $q will always be set, since it is capturing the value of mysql_query(). You should run a test for: if(file_exists(...))  Quote Link to comment Share on other sites More sharing options...
runnerjp Posted December 7, 2007 Author Share Posted December 7, 2007 like $sql = "SELECT `ext` FROM `user_images` WHERE `user_id`='$username' LIMIT 1"; $q = mysql_query($sql) or die("Error running query:".mysql_error()); if($q){  $row = mysql_fetch_array($q);  if(file_exists($row))   echo "<img src='http://www.runningprofiles.com/members/images/".     $pid . "." . $row['ext']     . "' />"; }{ else  echo 'Error: Image not found.';  }    Quote Link to comment Share on other sites More sharing options...
runnerjp Posted December 7, 2007 Author Share Posted December 7, 2007 ok this is wired had it all working now wont display the echo or an image  $sql = "SELECT `ext` FROM `user_images` WHERE `user_id`='$username' LIMIT 1"; $q = mysql_query($sql) or die("Error running query:".mysql_error()); if($q){  $row = mysql_fetch_array($q);  if(!empty($row)){   echo "<img src='http://www.runningprofiles.com/members/images/".     $pid . "." . $row['ext']     . "' />";  } }else{  echo 'Error: Image not found.';  }   no errors just doent display anything...a blank page yet it did afew minutes ago :S 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.