troubleshooting Question

PHP/Mysql: Why only one row returned?

Avatar of Michel Plungjan
Michel PlungjanFlag for Denmark asked on
4 Comments3 Solutions580 ViewsLast Modified:
I have the following code

myArray = new Array();
$whereStmt = ' ID="'.$ID.'" AND idx="'.addslashes($passed).'"'; // ID=4, idx = 310;
$selectSql = 'SELECT * FROM myTable WHERE '.$whereStmt ;
$Result    = $MyDb->f_ExecuteSql($selectSql);
$Resultset = $MyDb->f_GetRecord($Result);

$ResultRowNr    = $MyDb->f_GetSelectedRows($Result);


echo "\n// sql:".$selectSql."\n"; // shows // sql:SELECT * FROM myTable WHERE  ID="4" AND idx="310"

while ($Resultset = $MyDb->f_GetRecord($Result)) {
  myArray[<? echo $counter; ?>] = '<? echo $Resultset['title']; ?>';

If I in a separate program I have

$whereStmt = ' ID = "'.&ID.'"; // id = 4

$selectSql = 'SELECT * FROM myTable WHERE '.$whereStmt ;

$Result    = $MyDb->f_ExecuteSql($selectSql);
$recordcount = $MyDb->f_GetSelectedRows();
if ($recordcount==0) {
  echo "After update/insert, I cannot find a record where ".$whereStmt;

echo "<br>Looked up the records after insert/update: ID: ".$ID;

while($row = mysql_fetch_array($Result)) {
  echo "<br>title:".$row['title']." idx: ".$row['idx'];

title:Test310Updated idx: 310

title:Test310Extra_updated idx: 310

In the first prgrams I only get to see the second title. E.g. the result is

  myArray[0] = 'Test310Extra_updated';

and not

  myArray[0] = 'Test310Extra';
  myArray[1] = 'Test310Extra_updated';

So it skips the first.

$ResultRowNr    = $MyDb->f_GetSelectedRows($Result);

have something to do with it? - I do not use it

Also what is the better method? resultSet or fetch?

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 3 Answers and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros