0

I need to take value form variable, hode one part and send the other part in email.

This variable is sql anywhere query result.

This is what i have so far:

$res=sqlanywhere_query(...)

$resID=explode('#',$res);
$email.=$email_footer.$resID[1].$email_footer2;

When I had in email $res, in email I get something liike Resource #163.

When I put $resID[1], in place where should be 163, space was empty.

Dan Barzilay
  • 4,974
  • 5
  • 27
  • 39
miszczu
  • 1,179
  • 4
  • 19
  • 39
  • What is the output of `print_r($resID)` ? – Danny Beckett Oct 05 '12 at 10:57
  • 1
    `Resource #163` means it is a resource object, you need to fetch data from it. – xdazz Oct 05 '12 at 10:57
  • I think `sqlanywhere_fetch_array` should work, I didn't though about that. I can't test it right now because machine where sqlanywhere is is off, but it should be ok. Thanks for help all. – miszczu Oct 05 '12 at 11:06

3 Answers3

2

That is because your $res is a resource, you have to get the results. You should have for that library something like

$sql = sqlanywhere_query(...)
$res = sqlanywhere_fetch($sql);

and $res will be an array with your query result;

Mihai Iorga
  • 39,330
  • 16
  • 106
  • 107
1

It's a resource, which means that it's a special variable that holds a reference to an external source.

See the PHP manual on Resources.

Wayne Whitty
  • 19,513
  • 7
  • 44
  • 66
1

please, using database with php. when you query, you must pass the result to a fetch function before you can access the values.

$res=sqlanywhere_query(...)

//fetch one
$data = sqlanywhere_fetch_row($res)

// or u loop through
while($row = sqlanywhere_fetch_row($res))
{
    echo $row["id"];
}

all these functiosn are deprecated. you can use mysql_query and mysql_fetch_row (or other fetch functions). you can also use mysqli_ functions. read PHP manual.

hope it helps

Nwafor
  • 184
  • 6