0

I have a problem that I think i understand the issue but I'm stuck for a resolution.

I have a sql query running in PHP as follows:

$sql = "select COUNT(*) From dbo
Where dbo.table.STATUS < 4";

$Backlog = sqlsrv_query($conn,$sql);
if( $Backlog === false) {
    die( print_r( sqlsrv_errors(), true) );
}
while( $Row = sqlsrv_fetch_array( $Backlog, SQLSRV_FETCH_NUMERIC) ) {
      echo $Row[0];
}

My connection to the source is fine and if I put this out via a basic PHP page I get the result of the query printed on the page.

However, I'm trying to call $Backlog on a different page with some CSS formatting:

<?php echo "<div class =second_row_label>Incident Back Log</div><div class =top_num>".$Backlog."</div></div></a>"; ?>

And it's here I'm getting the Resource ID #x error.

From scanning the various pages I believe $Backlog is my resource so the question is, how can I call the result as the variable $Backlog on the second sheet?

2
  • What exactly are you trying to display there, one of the values that you retrieved from the database? If so, which one? Commented Sep 29, 2017 at 13:46
  • I'm doing a count from the DB and I want to display the value in the second page. calling the value from the first page. In effect I want the entire initial query and thus result to be the variable $Backlog so when I call the result on the second page it outputs the values from the DB query in the initial page. Commented Sep 29, 2017 at 13:51

1 Answer 1

1

If I understand your question correctly I think sessions will solve your problem.

Store your values to $_SESSION variables. You can then use those $_SESSION variable on any page that includes session_start()

Sign up to request clarification or add additional context in comments.

1 Comment

Worked like a charm once I worked out where to put the $_SESSION syntax. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.