Jump to content

Problem using the explode function


freakness883

Recommended Posts

I have the following code:
[quote]<?php
    $query3 = "SELECT members FROM groups WHERE g_id='".$id."'";
echo "$query3";
    $result3 = mysql_query("SELECT members FROM groups WHERE g_id='1'");
$row = mysql_fetch_row($result3);
    $pieces = explode(" ", $row);
echo $pieces[0];
echo $pieces[1];
if (in_array("bbaker", $pieces)) {
  echo "Got bbaker";
}
else{
  echo "nope";
}
[/quote]

[b]echo "$query3"[/b] is printing out the proper select statement -- runnning the statement manually in MySQL gets me the record "bbaker bbarker". But when I echo [b]$pieces[0][/b] and [b]$pieces[1][/b] I get the output [b]Array[/b] for both. I was hoping for bbaker and bbarker. And also I'm returning false on the condition [b]in_array("bbaker", $pieces)[/b]. Something's wrong with my SQL query. Any help is appreciated.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.