Bullet Posted August 21, 2008 Share Posted August 21, 2008 <th class="TableArea" scope="row"><div align="center"><? print"<a href='profile.php?viewuser=$buttock->target'>$buttock->target</a>"; ?></div></th> <td class="TableArea"><div align="center"><? print"".maketime($buttock->stime).""; ?> <? $f_query222=mysql_query("SELECT location FROM users WHERE username='$s_query->target'"); $gett=mysql_fetch_object($f_query222); if($buttock->status == Success){ echo "Success, found in $gett->location."; }elseif($buttock->status == Pending){ echo "- Search pending."; }elseif($buttock->status == Failed){ echo "Search failed."; } ?></div></td> But it won't get the location when it's a success, anyone know why? Link to comment https://forums.phpfreaks.com/topic/120630-solved-get-my-location/ Share on other sites More sharing options...
trq Posted August 21, 2008 Share Posted August 21, 2008 Assuming Success, Pending and Failed are meant to be strings they need be surrounded in quotes. eg; if($buttock->status == 'Success') { besides that, how do you know your query is working? Youy fail to check. Link to comment https://forums.phpfreaks.com/topic/120630-solved-get-my-location/#findComment-621582 Share on other sites More sharing options...
Bullet Posted August 21, 2008 Author Share Posted August 21, 2008 Makes no difference I've changed the query though to: $f_query222=mysql_query("SELECT location FROM users WHERE username='$buttock->target'"); Link to comment https://forums.phpfreaks.com/topic/120630-solved-get-my-location/#findComment-621583 Share on other sites More sharing options...
trq Posted August 21, 2008 Share Posted August 21, 2008 Your query is likely failing, you need to check it succeeds prior to using anything it might return. <?php if ($f_query222 = mysql_query("SELECT location FROM users WHERE username='{$buttock->target}'")) { if (mysql_num_rows($f_query222)) { $gett = mysql_fetch_object($f_query222); if ($buttock->status == 'Success') { echo "Success, found in $gett->location."; } elseif ($buttock->status == 'Pending') { echo "- Search pending."; } else { echo "Search failed."; } } else { echo "Search failed."; } } else { echo "Query failed<br />" . mysql_error(); } ?> ps: Complex variables ought be surrounded by curly braces when within strings. Link to comment https://forums.phpfreaks.com/topic/120630-solved-get-my-location/#findComment-621602 Share on other sites More sharing options...
Bullet Posted August 21, 2008 Author Share Posted August 21, 2008 Thanks so much! Link to comment https://forums.phpfreaks.com/topic/120630-solved-get-my-location/#findComment-621855 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.