1

I am using SQL Anywhere in php, i use something like this:

sasql_connect ("Uid=".$uid.";Pwd=".$password.";ServerName=".$servername.";CommLinks=tcpip(host‌​=".$ip.";port=".$port.")");
$result = sasql_query("SELECT * FROM cars");

When i use:

while($row = sasql_fetch_array($result)) {
}

I get:

Warning: sasql_fetch_array(): 27 is not a valid SQLAnywhere result resource in ...

When i use:

echo get_resource_type($result);

I get 'SQLAnywhere result'

Also other functions like sasql_num_rows() don't work, what could be a reason this doesn't work? It looks like the resource is not recognized. I am 100% sure there is no error in the SQL query.

Michael Berkowski
  • 267,341
  • 46
  • 444
  • 390
Chris
  • 1,068
  • 2
  • 14
  • 30
  • what about your database connection strings? ca you post them too? – Astha Oct 01 '11 at 14:02
  • Sure: sasql_connect ("Uid=".$uid.";Pwd=".$password.";ServerName=".$servername.";CommLinks=tcpip(host=".$ip.";port=".$port.")"); – Chris Oct 01 '11 at 14:10
  • Assign the connection resource to a variable like $conn. Then try this: echo(sasql_error($conn)); after the connection and also after the query. – Sebastián Grignoli Oct 01 '11 at 15:15
  • Hey Sebastian, i did that already, there is no error. :( – Chris Oct 01 '11 at 15:19
  • I fixed it, for some odd reason the sasql_error() function cleared the resource, i did that before the sasql_fetch_array(). Thanks everyone. – Chris Oct 01 '11 at 16:10
  • I would shame myself for some minutes after discovered such error from myself! – Ismael Oct 03 '11 at 19:19

0 Answers0