Can make insert but no select from php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
goremo
Forum Newbie
Posts: 3
Joined: Sun Jun 26, 2005 3:35 am

Can make insert but no select from php

Post 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>';
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

var_dump() the "object" .. it should give you an idea of how to get the data you requested.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Don't forget to use

Code: Select all

 when posting PHP code.
Post Reply