Jump to content

[SOLVED] Get my Location!


Bullet

Recommended Posts

    <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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.