JonnyDriller Posted February 27, 2020 Share Posted February 27, 2020 I have a situation were I need to just get a simple location. I don't want any while loops or any of that jazz. I just want 1 string location every time. <?php $ider = $_GET['id']; $conn = mysqli_connect("localhost", "Me", "pass", "MyDB"); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT Location FROM LifeSaver1 WHERE id =$ider"; $result = $conn->query($sql); $obj = mysqli_fetch_object($result); $obj2 = $obj->Location; var_dump($obj); ?> This is what it outputs Quote string(11) "Boston" I just need Boston. Can anyone give me a hint? Quote Link to comment Share on other sites More sharing options...
ginerjm Posted February 27, 2020 Share Posted February 27, 2020 How about "echo $obj2"; ?? 1 Quote Link to comment Share on other sites More sharing options...
JonnyDriller Posted February 27, 2020 Author Share Posted February 27, 2020 No way... facepalm... ahh well I think I learned a good bit. Legend @ginerjm thx m8 Quote Link to comment Share on other sites More sharing options...
ginerjm Posted February 27, 2020 Share Posted February 27, 2020 HTH! Quote Link to comment Share on other sites More sharing options...
Psycho Posted February 28, 2020 Share Posted February 28, 2020 For that matter, why have $obj2 at all! Just use $obj->Location where you want that value. 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.