Page 1 of 1

Can make insert but no select from php

Posted: Mon Aug 08, 2005 8:42 am
by goremo
The code below works on my server but shows the following problems at my ISP (win server 2003, php 5.0). I can make insert but no select from php to microsoft sql 2000.

The script shows 'object' inplace of any data where such syntax($CurrentUser=$rs->Fields(0);) are used.

NB: The same code can successfully perform insert and can show the number of fields using ($num_columns = $rs->Fields->Count();)

What correction or modification can apply (my ISP wont change their php setting, is there some way round)



$conn = new COM("ADODB.Connection") or die("Cannot start ADO");

$conn->Open("Provider=SQLOLEDB.1;Data Source= servername;User ID=user;Password=password;Initial Catalog=db_name;");

$query="SELECT currentUser FROM ActivityLog WHERE sessionid = (select Max(sessionID) from ActivityLog)" ;

$rs = $conn->Execute($query); // Recordset

$num_columns = $rs->Fields->Count();

$CurrentUser=$rs->Fields(0);
echo '<p>' . $num_columns . '</p>';
echo '<p>' . $CurrentUser . '</p>';

Posted: Mon Aug 08, 2005 8:59 am
by feyd
var_dump() the "object" .. it should give you an idea of how to get the data you requested.

Posted: Mon Aug 08, 2005 10:51 am
by Ambush Commander
Don't forget to use

Code: Select all

 when posting PHP code.